To clear event(s) of another thread
To clear event(s) of another thread
chibi RT provides API to clear event in current task with chEvtGetAndClearEvents(eventmask_t). Now what I need is to clear event(s) of another thread. Suppose I know the thread reference, it seems I can just lock and directly manipulate thd->epending &= ~event. But is it safe? Shall I check thread priority? Shall I check whether the other thread is already in ready to run list? Is there any other protection I should add?
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: To clear event(s) of another thread
Hi,
It would be safe if done in a critical zone, so use chSysLock/Unlock.
Giovanni
It would be safe if done in a critical zone, so use chSysLock/Unlock.
Giovanni
Re: To clear event(s) of another thread
Giovanni wrote:Hi,
It would be safe if done in a critical zone, so use chSysLock/Unlock.
Giovanni
Wouldn't one also need to preform a reschedule before exiting the critical zone?
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: To clear event(s) of another thread
Clearing events would not wake up a thread so rescheduling is not required. It only has to be performed after that the state of the ready list has changed, usually after calling chSchReadyI().
Giovanni
Giovanni