From 5b2c3f2c89ff77520b4597a4d15a2991aa48bf4b Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Fri, 2 Apr 2021 16:18:19 +0800 Subject: [PATCH] fix pthread_create timing bug --- kal/posix/src/pthread.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kal/posix/src/pthread.c b/kal/posix/src/pthread.c index a7e8893e..cd5d8702 100644 --- a/kal/posix/src/pthread.c +++ b/kal/posix/src/pthread.c @@ -97,7 +97,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, taskInitParam.pfnTaskEntry = PthreadEntry; taskInitParam.uwArg = (UINT32)(UINTPTR)pthreadData; - if (LOS_TaskCreate(&taskID, &taskInitParam) != LOS_OK) { + if (LOS_TaskCreateOnly(&taskID, &taskInitParam) != LOS_OK) { free(pthreadData); return EINVAL; } @@ -105,6 +105,8 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, /* set pthread default name */ (void)sprintf_s(taskInitParam.pcName, PTHREAD_NAMELEN, "pthread%u", taskID); + (void)LOS_TaskResume(taskID); + *thread = (pthread_t)taskID; return 0; } -- GitLab