How can kernel run all the time?

不打扰是莪最后的温柔 提交于 2019-12-13 02:30:27

问题


How can kernel run all the time, when CPU can execute only one process at a time ? That is, if kernel is occupying CPU all the time , then how come other processes run.

Please explain Thank You


回答1:


In the same way that you can run multiple userspace processes at the same time: Only one of them is actually using the CPU at any given time. You have some interrupts that force them to give it up.

Code that is part of the operating system is no different here (except that it is in control of setting up this scheduling in the first place).

You also have to distinguish between processes run by the OS in the background (I suppose that is what you are talking about here), and system calls (which are being run as part of "normal" processes that temporarily switch into supervisor mode).



来源:https://stackoverflow.com/questions/33006604/how-can-kernel-run-all-the-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!