Topics

Device Drivers


Raj Gundi
 

Hi,

 

I had a question regarding the device driver modelling in Zephyr. I see that most device drivers in Zephyr are not 'thread sensitive'. That is, there is a possibility of some unintended behaviour when 2 or more threads concurrently access the driver. Of course, this situation is mostly relevant only for pre-emptive threads. I wanted to know if there’s some reason for this design. Also, I wanted to brainstorm the different possible ways to make these drivers thread-safe when using pre-emptive threads. Below are some of the ways that I could think of.

a.       Modify the drivers in Zephyr to be thread-safe. Mutexes can be used here. 

b.       Have a wrapper in app layer for each of the drivers through which the corresponding drivers are accessed. Mutexes can be used here to guarantee thread sensitivity. 

c.       Have a dedicated thread (supervisor/worker thread) whose only job is to issue driver calls. Though this approach can separate out the user space from kernel space which is desirable, it may also increase the frequency of task switches thereby adversely affecting performance.

 

Please let me know your views.

 

Regards,

Raj