谁来调度操作系统中的调度程序——这不是先有鸡还是先有蛋的情况吗?

发布于 2024-08-21 04:54:57 字数 182 浏览 7 评论 0原文

谁来安排调度程序?

创建的第一个任务是什么?第一个任务是如何创建的?它不需要任何资源或内存吗?这不是像先有鸡还是先有蛋的情况吗?

调度程序不是一个任务吗?它是否在每个时间片结束时获取CPU来检查哪个任务需要给CPU?

有没有什么好的链接可以让人深入思考和理解所有这些概念,而不是说出一些需要牢记的理论?

Who schedules the scheduler?

Which is the first task created and how is this first task created? Isn't any resource or memory required for it? isn't like a chicken and egg scenario?

Isn't scheduler a task? Does it get the CPU at the end of each time slice to check which task needs to be given CPU?

Are there any good links which makes a person think and understand deeply all these concepts rather than spilling out some theory which needs to be byhearted?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云淡月浅 2024-08-28 04:54:57

调度程序由

  • (外部)事件调度,例如中断,(磁盘完成,鼠标单击,计时器滴答)
  • 或内部事件(例如线程完成,线程发出需要等待某些事情的信号) ,或线程已释放资源的信号,或由线程执行非法操作(如除以零)引起的陷阱)

简而言之,它由任何可能需要运行任务集的事件触发/或要重新评估这些任务的优先级。调度程序决定接下来运行哪些任务,并将控制权传递给下一个任务。

通常,调度器的这种“调度”是由与硬件中断相关联的代码或与系统调用相关联的代码引起的。

虽然您可以将调度程序视为真正的线程,但实际上它不需要以这种方式实现......因为它的执行优先级高于任何其他任务。事实上,复杂的操作系统可能会预留一个特殊的线程作为调度程序,并在调度程序获得控制权时将其标记为忙碌。这使得它很漂亮,但是伪造的线程不是由调度程序调度的

一个可以有多个调度程序:最高优先级的调度程序(例如我们刚刚描述的那个),以及其他真正是线程的调度程序,并且像其他用户一样运行任务。这种较低优先级的调度程序往往用于管理间隔时间较长的操作,例如后台作业。

The scheduler is scheduled by

  • an (external) event such as an interrupt, (disk done, mouse click, timer tick)
  • or an internal event (such as the completion of a thread, the signalling by a thread that it needs to wait for something, or the signalling of a thread that it has released a resource, or a trap caused by a thread doing something illegal like division by zero)

In short, it is triggered by any event that might require that the set of tasks to be run and/or the priorities of those tasks to be reevaluated. The scheduler decides which task(s) run next, and passes control to the next task.

Typically, this "scheduling" of the scheduler is caused by the code associated with a hardware interrupt, or code associated with a system call.

While you can think of the scheduler as being a real thread, in practice it doesn't need to be implemented that way... because it is executed with higher priority than any other task. Sophisticated OSes may in fact set aside a special thread that is the scheduler, and mark it busy when the scheduler gets control. That makes it pretty, but the bogus thread isn't scheduled by the scheduler

One can have multiple schedulers: the highest priority one (e.g., the one we just described), and other schedulers which really are threads, and are run like other user tasks. Such lower priority schedulers tend to be used to manage actions which occur at much longer intervals, such as background jobs.

寻找我们的幸福 2024-08-28 04:54:57

它通常由定时 CPU 中断定期调用

it is usually invoked periodically by a timed CPU interrupt

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文