IssueNo:#!3456
Description:修复setitimer多核静态问题 Sig:kernel Feature or Bugfix:Bugfix Binary Source:No Change-Id: I43661908d0d5248f70acb16ea95dc76fcdb6a84e
This commit is contained in:
parent
c70335c80d
commit
7256d67a1c
|
@ -883,8 +883,10 @@ clock_t times(struct tms *buf)
|
||||||
|
|
||||||
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
|
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
|
||||||
{
|
{
|
||||||
|
UINT32 intSave;
|
||||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||||
|
timer_t timerID = 0;
|
||||||
struct itimerspec spec;
|
struct itimerspec spec;
|
||||||
struct itimerspec ospec;
|
struct itimerspec ospec;
|
||||||
int ret = LOS_OK;
|
int ret = LOS_OK;
|
||||||
|
@ -894,15 +896,28 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
|
||||||
set_errno(EINVAL);
|
set_errno(EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
LOS_TaskLock();
|
|
||||||
|
/* To avoid creating an invalid timer after the timer has already been create */
|
||||||
if (processCB->timerID == (timer_t)(UINTPTR)MAX_INVALID_TIMER_VID) {
|
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) {
|
if (ret != LOS_OK) {
|
||||||
LOS_TaskUnlock();
|
|
||||||
return ret;
|
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)) {
|
if (!ValidTimeval(&value->it_value) || !ValidTimeval(&value->it_interval)) {
|
||||||
set_errno(EINVAL);
|
set_errno(EINVAL);
|
||||||
|
|
Loading…
Reference in New Issue