OS locking during HAL configuration

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Gnam
Posts: 2
Joined: Wed Oct 13, 2021 4:27 pm

OS locking during HAL configuration

Postby Gnam » Wed Oct 13, 2021 4:29 pm

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.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: OS locking during HAL configuration

Postby Giovanni » Wed Oct 13, 2021 5:44 pm

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

Gnam
Posts: 2
Joined: Wed Oct 13, 2021 4:27 pm

Re: OS locking during HAL configuration

Postby Gnam » Wed Oct 13, 2021 7:29 pm

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.


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 8 guests