update src/thread/pthread_create.c.

This commit is contained in:
caifuzhou
2021-12-27 03:33:56 +00:00
committed by Gitee
parent 36f929af7e
commit 5b9dcfe0b8
+2 -4
View File
@@ -236,8 +236,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
sigset_t set;
if (!libc.can_do_threads) return ENOSYS;
self = __pthread_self(); //将进程id的值赋给主线程
self->pid = __syscall(SYS_getpid);
self = __pthread_self();
if (!libc.threaded) {
for (FILE *f=*__ofl_lock(); f; f=f->next)
init_file_lock(f);
@@ -360,7 +359,6 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
}
if (ret >= 0) {
new->pid = self->pid; //新创建的线程获取进程id
new->next = self->next;
new->prev = self;
new->next->prev = new;
@@ -412,6 +410,6 @@ struct pthread* __pthread_list_find(pthread_t thread_id, const char* info)
pid_t __pthread_gettid(pthread_t t)
{
struct pthread* thread = __pthread_list_find(t, "pthread_gettid");
return thread ? thread->pid : -1;
return thread ? thread->tid : -1;
}
weak_alias(__pthread_gettid, pthread_gettid);