'Semaphore under uCOS-III

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



Solution 1:[1]

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);
...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Clifton Kor