Hi!
While calling normal class functions is only allowed from normal state, what about non-normal class functions? Do they have to be called exclusively from their non-normal state or may they be called from normal state as well?
Christian
Calling non-normal class functions from normal state
Moderators: RoccoMarco, lbednarz, tfAteba
Re: Calling non-normal class functions from normal state
Hi!
I've just found out the answer myself:
(from "Common Mistakes")
I've just found out the answer myself:
Use of S-class or I-class APIs outside a proper lock state.
(from "Common Mistakes")
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Calling non-normal class functions from normal state
Hi,
Correct, look at the states diagram into the "Kernel Concepts" chapter in the documentation. You can go from Normal state to a Lock state using specific functions: chSysLock(), chSysUnlock(), chSysLockFromIsr(), chSysUnlockFromIsr().
Note that all I-Class functions never reschedule internally so you may have to force a reschedule before exiting a lock zone, for example:
The above mechanism is also used to create combined atomic primitives, for example signaling a semaphore and generating an event atomically.
Giovanni
Correct, look at the states diagram into the "Kernel Concepts" chapter in the documentation. You can go from Normal state to a Lock state using specific functions: chSysLock(), chSysUnlock(), chSysLockFromIsr(), chSysUnlockFromIsr().
Note that all I-Class functions never reschedule internally so you may have to force a reschedule before exiting a lock zone, for example:
Code: Select all
chSysLock();
chSemSignalI(....); /* Does not reschedule by itself but could wakeup an higher priority thread.*/
chSchRescheduleS(); /* Checks if a reschedule is required, if so reschedules.*/
chSysUnlock();
The above mechanism is also used to create combined atomic primitives, for example signaling a semaphore and generating an event atomically.
Giovanni
Re: Calling non-normal class functions from normal state
Hi, Giovanni!
Thanks for the reply. I've read the kernel concepts chapter before posting. Having read it yet again I must confess that I must have skipped over the relevant part right at the top of the page. Mea culpa!
Christian
Thanks for the reply. I've read the kernel concepts chapter before posting. Having read it yet again I must confess that I must have skipped over the relevant part right at the top of the page. Mea culpa!
Christian