!55 【轻量级 PR】:fix pthread_create timing bug

Merge pull request !55 from Caoruihong/N/A
This commit is contained in:
openharmony_ci 2021-04-02 18:01:27 +08:00 committed by Gitee
commit 4fc4b8c9c1
1 changed files with 3 additions and 1 deletions

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