Page 1 of 1

OS locking during HAL configuration

Posted: Wed Oct 13, 2021 4:29 pm
by Gnam
Hello,

I am currently starting the evaluation of ChibiOs as the RT OS for one of my projects and I have a question regarding the OS locking mechanism on Cortex M3/4 targets.

I took a look at the device driver model and it appears that every time I want to configure a device (with spiStart() for example) the osalSysLock() function is called, preventing (as I understand it) any context switching during the configuration process.

Could you please confirm that (or not)?

Thank you.

Re: OS locking during HAL configuration

Posted: Wed Oct 13, 2021 5:44 pm
by Giovanni
Hi,

Lock/unlock operations are used for implementing critical sections, on Cortex-M this is achieved by raising the value into the BASEPRI register.

Their use prevents IRQ servicing until the initialization is complete which happens in a small finite time, it is a simple procedure, IRQ are not lost but just delayed until osalSysUnlock().

Critical sections are used across the HAL, not just when configuring peripherals, it is done in order to keep certain operations atomic.

Giovanni

Re: OS locking during HAL configuration

Posted: Wed Oct 13, 2021 7:29 pm
by Gnam
Thank you for your quick reply Giovanni.

That is what I thought. And unfortunately it is a big no-go for me, such a (thread) latency is unacceptable for most of my projects.
And I still don't see the point. The (small piece of) code that I reviewed can be interrupted without any issue and doesn't need any kernel locking mechanism.

From my point of view it kills the benefits of a called-fast RT kernel.