How does the OS scheduler regain control of CPU?

前端 未结 3 613
深忆病人
深忆病人 2020-12-12 13:20

I recently started to learn how the CPU and the operating system works, and I am bit confused about the operation of a single-CPU machine with an operating system that provi

3条回答
  •  长情又很酷
    2020-12-12 13:50

    The OS sets up a hardware timer (Programmable interval timer or PIT) that generates an interrupt every N milliseconds. That interrupt is delivered to the kernel and user-code is interrupted.

    It works like any other hardware interrupt. For example your disk will force a switch to the kernel when it has completed an IO.

提交回复
热议问题