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
chBSemWaitTimeout
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: chBSemWaitTimeout
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
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