Semaphore under uCOS-III

213 Views Asked by At

I use uCOS-III under Arm Cortex M4 and have the following problem:

If OSSemPend() is executed twice within the same task), like

timeout = 100; /* 0.1 s */
OSSemPend(rtos_sem_p, timeout, OS_OPT_PEND_BLOCKING, NULL, &err);
...
OSSemPend(rtos_sem_p, timeout, OS_OPT_PEND_BLOCKING, NULL, &err);
...

(without issuing OSSemPost()) it will not run into the timeout at the second call but block infinitely.

I checked what I can, but still cannot find the problem... Can anybody explain me what happens here?

Many Thanks,

Michael

1

There are 1 best solutions below

0
Clifton Kor On

Try adding time

CPU_TS ts;
timeout = 100; /* 0.1 s */
OSSemPend(rtos_sem_p, timeout, OS_OPT_PEND_BLOCKING, &ts, &err);
...
OSSemPend(rtos_sem_p, timeout, OS_OPT_PEND_BLOCKING, &ts, &err);
...