To clear event(s) of another thread

Discussions and support about ChibiOS/RT, the free embedded RTOS.
xiaomin
Posts: 6
Joined: Mon Jul 24, 2017 1:43 pm
Has thanked: 1 time

To clear event(s) of another thread

Postby xiaomin » Tue Oct 30, 2018 8:38 pm

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?

User avatar
Giovanni
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: To clear event(s) of another thread

Postby Giovanni » Wed Oct 31, 2018 5:06 am

Hi,

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

Giovanni

faisal
Posts: 189
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 27 times
Been thanked: 21 times

Re: To clear event(s) of another thread

Postby faisal » Wed Oct 31, 2018 6:48 am

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?

User avatar
Giovanni
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: To clear event(s) of another thread

Postby Giovanni » Wed Oct 31, 2018 6:57 am

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


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 4 guests