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

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

问题描述

谁安排了调度程序?

第一个任务是哪个创建的,第一个任务是如何创建的?是否不需要任何资源或内存?不像是鸡和鸡蛋的场景吗?

不是调度任务吗?是否在每个时间片的末尾获取CPU来检查需要为哪个任务分配CPU?

是否有任何良好的联系可以使一个人深入地思考和理解所有这些概念,而不是浪费一些需要发自内心的理论?

解决方案

调度程序由

调度
  • (外部)事件,例如中断,(磁盘已完成,鼠标单击,计时器滴答声)
  • 或内部事件(例如线程的完成,线程需要等待某事的信号,或者线程已释放资源的信号或由线程执行该操作而导致的陷阱)非法除零之类的东西)
简而言之,它是由可能需要运行一组任务和/或重新评估这些任务的优先级的任何事件触发的.调度程序决定下一步执行哪个任务,并将控制权传递给下一个任务.

通常,调度程序的这种调度"是由与硬件中断相关的代码或与系统调用相关的代码引起的.

尽管您可以将调度程序视为一个真正的线程,但实际上并不需要那种方式实现……因为它的执行优先级高于任何其他任务.实际上,复杂的OS可能会预留一个专门的线程作为调度程序,并在调度程序获得控制权时将其标记为忙.这很漂亮,但是伪线程不是由调度程序调度的.

一个调度程序可以具有多个调度程序:优先级最高的调度程序(例如,我们刚刚描述的调度程序)和其他调度程序,它们实际上是线程,并且像其他用户任务一样运行.这种优先级较低的调度程序通常用于管理间隔较长的操作,例如后台作业.

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?

解决方案

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.

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

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