特殊情况下的调度 [英] Special case scheduling

查看:174
本文介绍了特殊情况下的调度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,这里的问题。在研究有关进程调度,我碰到两个看似矛盾的例子我不能让我的头左右。

So here's the question. While studying about process scheduling I came across two seemingly contradictory examples I just can't get my head around.

问题出现如果例如在优先非preemptive调度算法,总是选择过程具有最高优先级待下一次运行运行,过程只能volontarily放弃其CPU时间,也就是没有其他进程可以运行,直到当前运行的进程结束。似乎有什么溶液中的书提出的是,如果发生在同一时间一个进程和新的高优先级的进程的到来的两端,新的高优先级的进程将被添加到就绪队列,然后通过所选择的调度下一个要运行

The problem arises if for instance in the priority non-preemptive scheduling algorithm which always chooses the process with the highest priority to be run next and once running, process can only volontarily give up its CPU time, that is no other process can run until the currently running process finishes. It seems that what the solution the book proposes is that if both end of one process and arrival of the new high-priority process occur at the same time, the new high-priority process will be added to the ready queue and then chosen by the scheduler to be run next.

但在循环算法的另一个例子,如果在就绪队列中只有一个进程,它正在运行,如果在同一时间的量子流逝,新工艺说,它的准备,似乎建议的解决方案是,所述调度将被首先进行,所以当前运行的进程将继续运行,而新的过程将被添加到队列。

But in the other example in Round-robin algorithm, if there is only one process in the ready queue and it is currently running, if at the same time its quantum elapses and new process says its ready, it seems that the proposed solution is that the scheduling will be done first, so the currently running process will continue to run while the new process will be added to the queue.

我会很感激,如果有人澄清这对我来说,因为我知道,从其他一些职位,上下文切换,不会出现在循环赛的队列中单一的过程,但它是在一般的事实,调度增加新前完成过程要排队。

I'd be grateful if someone clarified this to me, because I know from some other post that context switch does not occur in round robin for single process in queue, but is it true in general that scheduling is done before adding new process to queue.

推荐答案

我从你的描述是:

时间0:

过程1使用它的时间片,例如启动5个单位。

Process 1 starts using its time slice, e.g. 5 units.

时间5:

工艺2到达。 过程1中所用了它的时间片,并补充。

Process 2 arrives. Process 1 used up its time slice and is replenished.

一个循环赛调度检查就绪队列随时间选择左侧的下一道工序。 在时间0您就绪队列是这样的:

A round robin scheduler checks the ready queue by selecting the next process with time left. At time 0 your ready queue looks like this:

P1

在时间5:

P1去那边P1 - > P2

P1 going over to P1 -> P2

的Tanenbaum写现代的操作系统:当一个进程用完它的时间片,它是入队在最后。所以会发生什么是,P1被重新入队前,P2入队的第一次。这节省了一个额外的上下文切换从P1至P2和回到P1。 如果你想P2应首先运行,那么你可以优先使用的基础循环赛。

Tanenbaum writes in Modern Operating Systems: When a process used up it's time slice, it is enqueued at the end. So what happens is, that P1 is enqueued again before P2 is enqueued for the first time. This saves an additional context switch from P1 to P2 and back to P1. If you want P2 to be run first, then you can use priority base round robin.

这篇关于特殊情况下的调度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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