Linux kernel process switching

Consider the keventd process. He spends all this time in kernel mode. Now, as far as I know, Linux checks to see if context switching is required while the process is switching from kernel mode to user mode, and as far as I know, keventd will never switch from kernel mode to user mode, therefore, how will the Linux kernel know when to turn it off?

+4
source share
1 answer

If the kernel was supposed to do as you say, and only check if the process should be disconnected upon explicit transition between the user and the kernel, the following cycle will lock the kernel of your computer:

while (1); 

Obviously, this does not happen on regular desktop operating systems. The reason this is continuity is that when after the process is completed, the kernel receives an alarm during the cutoff, performs the steps and forcibly switches contexts as necessary.

Continuity, in principle, can work for kernel processes. However, I'm not sure what keventd does is more likely that it voluntarily gives up its temporary fragment on a regular basis (see sched_yield , sched_yield user space for the same effect), especially since the kernel can be configured to be unmanageable. This is the prerogative of the core process.

+4
source

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


All Articles