Semaphores and blocking - wait a full tick?
Posted: Tue Jul 30, 2019 5:47 am
A question regarding blocking on a semaphore - if you block on a mutex and then the mutex is freed by another task, do you immediately (or quickly) unblock, or do you have to wait for a TICK of the OS?
I'm working on a two-thread application (one for computation, the other one servicing Wifi packets via an AsyncUDP listen function). To pass information between the two, I'll have "volatile" values controlled by a mutex. I would normally just block with an infinite timeout on the mutex to access the data, but if that means I wait for a full FreeOS Tick, that'll be a HUGE delay (1/100 of a second is a LOT). In which case I'll just use a timeout of 0, and busy-wait by calling a small delay in the code between attempts. Ugly, but with only two threads probably not an issue.
I'm working on a two-thread application (one for computation, the other one servicing Wifi packets via an AsyncUDP listen function). To pass information between the two, I'll have "volatile" values controlled by a mutex. I would normally just block with an infinite timeout on the mutex to access the data, but if that means I wait for a full FreeOS Tick, that'll be a HUGE delay (1/100 of a second is a LOT). In which case I'll just use a timeout of 0, and busy-wait by calling a small delay in the code between attempts. Ugly, but with only two threads probably not an issue.