谁在 OS 中调度调度程序 - 这不是先有鸡还是先有蛋的场景吗? [英] Who schedules the scheduler in OS - Isn't it a chicken and egg scenario?

查看:16
本文介绍了谁在 OS 中调度调度程序 - 这不是先有鸡还是先有蛋的场景吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁调度调度器?

第一个任务是创建的,第一个任务是如何创建的?它不需要任何资源或内存吗?不像是先有鸡还是先有蛋的场景?

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?

调度器不是任务吗?它是否在每个时间片结束时获取 CPU 以检查需要为哪个任务分配 CPU?

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?

推荐答案

调度器被调度

  • 一个(外部)事件,例如中断、(磁盘完成、鼠标点击、计时器滴答)
  • 或内部事件(例如线程完成、线程发出需要等待某事的信号、或线程释放资源的信号、或由线程执行而导致的陷阱)像被零除这样的违法行为)

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

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.

这篇关于谁在 OS 中调度调度程序 - 这不是先有鸡还是先有蛋的场景吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆