什么是循环调度?
在多任务操作系统环境中,有时您会听到术语“循环调度”。 它指的是什么?
还有什么其他类型的调度?
In a multitasking operating system context, sometimes you hear the term round-robin scheduling. What does it refer to?
What other kind of scheduling is there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
时间片是实践中任何循环调度系统所固有的,据我所知。
我不同意 InSciTek Jeff 的暗示,即以下是循环调度:
我不明白这如何被认为是循环赛。 这实际上就是抢占式调度。 然而,可以有一个同时具有循环调度和抢占式调度元素的调度算法,如果同时启用循环调度和抢占(默认情况下禁用循环调度),VxWorks 就会执行此操作。 启用循环调度的方法是在kernelTimeSlice中提供一个非零值。
我非常同意这个说法:
你是对的,它不需要相等的时间。 抢占可能会破坏这一点。 实际上在VxWorks中,如果一个任务在循环调度期间被抢占,当该任务再次获得控制权时,它将在分配的剩余时间内执行。
针对 InSciTek Jeff 的编辑(我没有评论权限)
是的,我指的是任务锁定/中断禁用,尽管我显然没有很好地表达这一点。 你的第二条评论抢先了我(哈!)。 我希望讨论更突出的一点,即您认为循环调度可以在没有时间切片的情况下存在。 或者您只是指基于相同时间的时间切片? 我不同意前者,但同意后者。 我渴望学习。 谢谢。
Edit2针对杰夫:
我不同意这个说法。 请参阅本文档第 2.2.3 节,标题为循环调度。
时间片是循环调度所固有的。 否则,您将依赖任务放弃 CPU 控制,而循环调度旨在解决这个问题。
Timeslicing is inherent to any round-robin scheduling system in practice, AFAIK.
I disagree with InSciTek Jeff's implication that the following is round-robin scheduling:
I do not see how this could be considered round-robin. This is actually preemptive scheduling. However, it is possible to have a scheduling algorithm which has elements of both round-robin and preemptive scheduling, which VxWorks does if round-robin scheduling and preemption are both enabled (round-robin is disabled by default). The way to enable round-robin scheduling is to provide a non-zero value in kernelTimeSlice.
I do agree with this statement:
You are right that it doesn't require equal time. Preemption can muck with that. And actually in VxWorks, if a task is preempted during round-robin scheduling, when the task gets control again it will execute for the rest of the time it was allocated.
Edit directed at InSciTek Jeff (I don't have comment privileges)
Yes, I was referring to task locking/interrupt disabling, although I obviously didn't express that very well. You preempted me (ha!) with your second comment. I hope to debate the more salient point, that you believe round-robin scheduling can exist without time slicing. Or did you just mean equal time based time slicing? I disagree with the former, but agree with the latter. I am eager to learn. Thanks.
Edit2 directed at Jeff:
I disagree with this statement. See this document section 2.2.3 with the heading Round-Robin Scheduling.
Timeslicing is inherent in round-robin scheduling. Otherwise you are relying on a task to give up CPU control, which round-robin scheduling is intended to solve.
循环安排
如果您是 100 名客人的聚会中的主持人,循环安排意味着您为每位客人花费 1 分钟(固定量)。 你一一地浏览每一位客人,100分钟后,你就会和每一位客人相处一分钟。 更多信息请参阅维基百科。
还有许多其他类型的调度,例如基于优先级(即最重要的人优先)、先来先服务、最早截止日期优先(即最早离开的人先离开)等。您可以通过谷歌搜索开始了解调度算法或查看 Wikipedia 上的调度
Round Robin Scheduling
If you are a host in a party of 100 guests, round-robin scheduling would mean that you spend 1 minute (a fixed amount) per guest. You go through each guest one-by-one, and after 100 minutes, you would have spent 1 minute with each guest. More on Wikipedia.
There are many other types of scheduling, such as priority-based (i.e. most important people first), first-come-first-serve, earliest-deadline-first (i.e. person leaving earliest first), etc. You can start off by googling for scheduling algorithms or check out scheduling at Wikipedia
一个观点。 我们似乎正在将两种机制交织在一起。 假设仅 OP 的原始断言“在多任务操作系统上下文中”,则
1 - 循环调度程序始终调度循环队列中的下一个项目。
2 - 调度程序如何重新获得控制权来执行调度是独立且不相关的。
我不同意 2 最流行的方法是时间切片/产量等待资源,但正如已经指出的,还有其他方法。 如果我没记错的话,第一台 Mac 没有使用时间切片,他们使用的是自愿产量/等待资源的产量(20 岁以上的脑细胞有时可能会出错;)。
An opinion. It seems that we are intertwining two mechanisms into one. Assuming only the OP's original assertion "In a multitasking operating system context" then
1 - A round robin scheduler always schedules the next item in a circular queue.
2 - How the scheduler regains control to perform the scheduling is separate and unrelated.
I don't disagree that the most prevalent method for 2 is time-slicing / yield waiting for resource, but as has been noted there are others. If I am not mistaken the first Mac's didn't utilize time-slicing, they used voluntary yield / yield waiting for resource (20+ year old brain cells can be wrong sometimes;).
这里的答案甚至维基百科文章都描述了循环调度本质上包括周期性时间切片。 虽然这很常见,但我相信循环调度和时间切片不完全相同。 当然,为了使时间切片有意义,在轮换到每个任务时隐含着循环调度,但是您可以在没有时间切片的情况下进行循环调度。 也就是说,循环轮换中具有相同优先级的每个任务都可以被允许运行,直到它们达到资源块条件,然后才可以轮换中的下一个任务运行。 换句话说,当存在同等优先级任务时,重新调度点不是时间抢占的。
上述思想实际上是在Wind River的VxWorks内核的情况下具体实现的。 在其优先级方案中,每个优先级的任务都会循环运行,但如果没有在内核中专门启用该功能,则不会进行时间切片。 这种灵活性的原因是为了避免已知在有限时间内运行到块中的时间切片任务的开销。
因此,虽然基于时间片的调度意味着循环调度,但循环调度不需要基于相等时间的时间片。
The answers here and even the Wikipedia article describe round-robin scheduling to inherently include periodic timeslicing. While this is very common, I believe that Round-Robin scheduling and timeslicing are not exactly the same thing. Certainly, for timeslicing to make sense, round-robin schedling is implied when rotating to each task, however you can do round-robin scheduling without having timeslicing. That is, each task at the same priority in the round-robin rotation can be allowed to run until they reach a resource block condition and only then having the next task in the rotation run. In other words, when equal priority tasks exist, the reschedling points are not time pre-emptive.
The above idea is actually realized specifically in the case of Wind River's VxWorks kernel. Within their priority scheme, tasks of each priority run round robin but do not timeslice without specifically enabling that feature in the kernel. The reason for this flexibility is to avoid the overhead of timeslicing tasks that are already known to run into a block within a well bounded time.
Therefore, while timeslicing based scheduling implies round-robin scheduling, round-robin scheduling does not require equal time based timeslicing.
事实上,您对抢占式调度和循环法感到困惑。 事实上RR是抢占式调度的一部分。
Actaully, you are getting confused with Preemptive scheduling and Round robin. Infact RR is part of Preemptive scheduling.
循环调度基于时间共享,也称为量子(CPU 一次给予任何进程的最大时间)。 队列中有多个进程(需要不同的时间来完成,也称为突发时间),CPU 必须处理所有这些进程,因此它会在进程之间不断切换,以便根据量子值为每个进程提供相等的时间。 这种类型的调度称为循环调度。
查看这个简单的视频,轻松了解循环调度:https://www.youtube.com /watch?v=9hw-_qJ55K4
Round Robin scheduling is based on time sharing also known as quantum (max time given by CPU to any process in one go). There are multiple processes(which require different time to complete aka burst time) in a queue and CPU has to process them all so it keeps switching between processes to give every process equal time based on the quantum value. This type of scheduling is known as Round Robin scheduling.
Checkout this simple video to understand round robin scheduling easily: https://www.youtube.com/watch?v=9hw-_qJ55K4
循环法是一种简单的调度算法,其中时间在没有优先级的作业之间平均分配。
例如 - 如果您有 5 个进程正在运行 - 每个进程将被允许运行 1/5 个时间单位,然后另一个进程才被允许运行。 循环通常很容易在操作系统中实现。
Round robin is a simple scheduling algorithm where time is divided evenly among jobs without priority.
For example - if you have 5 processes running - each process will be allowed to run for 1/5 a unit of time before another process is allowed to run. Round robin is typically easy to implement in an OS.