Question

I am running an application,where certain user threads must not be preempted by kernel .I will explain my setup: OS: Linux 2.6.32 kernel

Kernel level: 1.There are many modules which are insmoded into kernel. 2.Work_queues are also initialized in some modules(I guess separate threads are created for work_queues) 3.If I am getting any hardware interrupt, I would queue this work in any of these initialized work_queue during my isr.

Application level: there are multiple threads running in parallel,some of which are of higher priority than any other thread in process.(Even kernel)

Objective: 1.If I get any hardware interrupt,isr will be automatically called in which work will be queued for any work_queue.But,I do not want scheduling of these work_queues if higher priority user level threads are running during that time.ie,certain User level threads should not be preempted by any work_queue handling in kernel.Now, i have observed that kernel gets priority than any other user thread. 2.I have multiple work_queues in kernel.How can i give different priority for different work queues.I havent seen any api to set priority for work_queues in kernel.

Was it helpful?

Solution

User threads must always be pre-emptible by kernel-mode threads because kernel-mode threads need to respond to hardware-events. This is by design.

If your user-mode threads need to interact with the hardware or are real-time and hence must not be pre-empted, consider making them kernel-mode threads.

If you are merely encountering errors caused by your thread being descheduled during a critical operation and ending up with another thread trampling over your operation, then you should implement locking.

If you have a custom need for breaking this fundamental design of the linux-kernel, you will need to change the behaviour of the kernel-mode scheduler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top