chBSemWaitTimeout

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

chBSemWaitTimeout

Post by Tabulous »

can one use chBSemWaitTimeout in interrupt context ?

ive got a shared data structure

A thread fills it with data.

RTC callback uses the data to update clk .


so need to protect the shared data structure, chBSemWaitTimeout fails in RTC callback
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chBSemWaitTimeout

Post by Giovanni »

Hi,

You can't "wait" in an ISR, the state checker would block this with an error. From ISR you can call only functions with the "I" suffix.

There are several approaches you could use, the most common are:

1) Use a critical zone for accessing your data from thread and ISR context: chSysLock, chSysUnlock, chSysLockFromISR, chSysUnlockFromISR.

2) Wake up a thread from the ISR and let the thread do the data handling, this is obviously heavier but could be required if your operation is too complex to be performed within a critical zone.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: chBSemWaitTimeout

Post by Tabulous »

was just about to comment that i've found that it needs to be do with lock/unlock

thanks for the reply :-)
Post Reply