!74 fix pthread_create timing bug

Merge pull request !74 from Caoruihong/pthread_create
This commit is contained in:
openharmony_ci
2021-04-19 11:46:19 +08:00
committed by Gitee

View File

@@ -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;
}