CPU timeout after waking up - linux scheduler

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

+4
source share
1 answer

You said you observed delays while writing. I think in this situation you can use schedule_timeout . Device drivers use this technique during recording to register so that they do not block the system. Recently, I ran into a problem when writing to the register causes delays; I plan to do schedule_timeout in my case too.

Priority settings, planning mode will not help here.

+1
source

Source: https://habr.com/ru/post/1497093/


All Articles