I start in the context of a driver in linux kernel - this driver writes a value to a register - an operation that takes some time (~ 5 ms). I would like to sleep at this time to give the processor to other threads - but it is very important for me to immediately return the processor back after I wake up (there is a short timeout that I should not exceed). The same question is about accepting a mutex — let's say I block the mutex (and causing recalculation) —how can I guarantee that I will immediately return the processor back when this mutex is released?
Is there any way to do this? what is this connected to? (priority setting for the process? special scheduling mode? kernel configuration change?)
EDIT: I will rephrase the mutex question as it is a bit more complicated: I have a mutex that is used by important threads (important because of this timeout limit). I would like to accept this mutex, knowing that if I lock it and get reschduled, the lock will be released quickly (because these threads will have high priority), and right after that my blocked thread will be able (and not some other, unrelated program). Thus, I can save processor time without risking a timeout violation. I am currently using wait to avoid rescheduling (my kernel is not proactive), but I don't like this.
Any help would be appreciated!
thanks
source share