提交 1c0bbb66 编写于 作者: 星e雨's avatar 星e雨

fix:setitimer are downregulated for multicore scenarios, and are static,...

fix:setitimer are downregulated for multicore scenarios, and are static, resulting in inconsistent behavior.

Close #I3EBOI

Change-Id: I71a86b8f2b7451e886a08dfc7f274287107df916
上级 d44f3904
......@@ -887,8 +887,10 @@ clock_t times(struct tms *buf)
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
{
UINT32 intSave;
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
timer_t timerID = 0;
struct itimerspec spec;
struct itimerspec ospec;
int ret = LOS_OK;
......@@ -898,15 +900,27 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
set_errno(EINVAL);
return -1;
}
LOS_TaskLock();
if (processCB->timerID == (timer_t)(UINTPTR)MAX_INVALID_TIMER_VID) {
ret = timer_create(CLOCK_REALTIME, NULL, &processCB->timerID);
ret = timer_create(CLOCK_REALTIME, NULL, &timerID);
if (ret != LOS_OK) {
LOS_TaskUnlock();
return ret;
}
}
LOS_TaskUnlock();
/* The initialization of this global timer must be in spinlock
* timer_create cannot be located in spinlock.
*/
SCHEDULER_LOCK(intSave);
if (processCB->timerID == (timer_t)(UINTPTR)MAX_INVALID_TIMER_VID) {
processCB->timerID = timerID;
SCHEDULER_UNLOCK(intSave);
} else {
SCHEDULER_UNLOCK(intSave);
if (timerID) {
timer_delete(timerID);
}
}
if (!ValidTimeval(&value->it_value) || !ValidTimeval(&value->it_interval)) {
set_errno(EINVAL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册