Code: Select all
chSysLock();
chFifoSendObjectS(&fifo, &data);
uint32_t size = chMBGetUsedCountI(&fifo.mbx);
chSysUnlock();
I noticed size is always 0. How is that possible? I single stepped thru chFifoSendObjectS() and confirmed it did a context switch to the thread waiting on that mailbox, it emptied it .. and then eventually context switched back to this thread and checked the size using chMBGetUsedCountI .... *all while inside an S-Locked state!*
I have all state checking debug options turned on, even the trace event log. I confirmed in the trace that it is indeed context switching.
When I look at the sequence of actions taken, I can see how a context switch occured ...
chSysLock()->chFifoSendObjectS->chMBPostTimeoutS->chSchRescheduleS->chSchDoRescheduleAhead->chSysSwitch->port_switch
I'm pretty sure no context switching or even non-fast interrupts should occur in an S-Lock state. What is going on?
From documentation:
S-Locked. Kernel locked and regular interrupt sources disabled. Fast interrupt sources are enabled. S-Class and I-Class APIs are invokable in this state.