Hi guys,
Just a quick one, can anyone confirm the behaviour of os_evt_get?
I'm wishing to share a buffer between two threads of different priority. When the thread of higher priority wishes to use the buffer, it sends a cease and desist event signal to the other thread.
I'm using Mutex locks but am concerned about the remote possibility of the cease and desist signal arriving in-between the lower priority thread waking up and locking the Mutex.
My thoughts were to lock the Mutex then re-check the event signaling, however the manual states:
"You can use the os_evt_get function to identify the event that caused the os_evt_wait_or function to complete."
Can I be sure that this function will always return the latest set of events, even if they've not yet been used to wake a thread?
Many thanks
The event function decides what flags that is waking up the thread at the moment it wakes up the thread - it doesn't care about other events that may happen.
But ignore the event. Just lock the mutex, do something, release. Then lock again, do something and relesae.
If the high-prio thread tries to get the mutex, it will have to wait until the low-prio thread releases the mutex. If it catches the mutex, then you can ignore the low-prio thread until the high-prio thread releases the mutex again.
So please explain again - why do you see a need to mix event and mutex to synchronizing the same thing?