repair the timeout for sem and mutex

This commit is contained in:
Wang_Weigen 2022-04-26 11:27:44 +08:00
parent 587c2d595e
commit afc4b58b74
2 changed files with 12 additions and 3 deletions

View File

@ -96,7 +96,12 @@ static x_err_t _MsgQueueSend(struct MsgQueue *mq,
tick_delta = 0;
task = GetKTaskDescriptor();
timeout = CalculteTickFromTimeMs(msec);
if(WAITING_FOREVER == msec)
timeout = WAITING_FOREVER;
else
timeout = CalculteTickFromTimeMs(msec);
lock = CriticalAreaLock();
if (mq->num_msgs >= mq->max_msgs && timeout == 0) {
CriticalAreaUnLock(lock);

View File

@ -94,8 +94,12 @@ static int32 _SemaphoreObtain(struct Semaphore *sem, int32 msec)
struct TaskDescriptor *task = NONE;
NULL_PARAM_CHECK(sem);
wait_time = CalculteTickFromTimeMs(msec);
if(WAITING_FOREVER == msec)
wait_time = WAITING_FOREVER;
else
wait_time = CalculteTickFromTimeMs(msec);
lock = CriticalAreaLock();
SYS_KDEBUG_LOG(KDBG_IPC, ("obtain semaphore: id %d, value %d, by task %s\n",