Page 1 of 1

To clear event(s) of another thread

Posted: Tue Oct 30, 2018 8:38 pm
by xiaomin
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?

Re: To clear event(s) of another thread

Posted: Wed Oct 31, 2018 5:06 am
by Giovanni
Hi,

It would be safe if done in a critical zone, so use chSysLock/Unlock.

Giovanni

Re: To clear event(s) of another thread

Posted: Wed Oct 31, 2018 6:48 am
by faisal
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?

Re: To clear event(s) of another thread

Posted: Wed Oct 31, 2018 6:57 am
by Giovanni
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