What context does the scheduler code run in?

前端 未结 3 413
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 22:11

There are two cases where the scheduler code schedule() is invoked-

  1. When a process voluntarily calls schedule()

  2. Timer

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-31 22:47

    When a process calls schedule() it runs in a system call context which is interrupt based. In the 2nd case a hardware interrupt triggers the schedule() call. In both cases it runs as an interrupt. AFAIK those are the only times that schedule() is called because most manipulation of scheduling involves modifying the kernel run queue of things to be scheduled although a process can be interrupted but that is usually done via an interrupt to tell the process to yield or the process yielding itself.

提交回复
热议问题