抢占式与非抢占式调度_抢占式和非抢占式调度之间的差异

抢占式与非抢占式调度

When the CPU is in the idle state, the CPU scheduler chooses a process from the ready queue and allocates the process to CPU. There are two types of scheduling,

当CPU处于空闲状态时,CPU调度程序从就绪队列中选择一个进程,并将该进程分配给CPU。 调度有两种类型,

  1. Preemptive Scheduling

    抢占式调度

  2. Non-Preemptive Scheduling

    非抢占式调度

1)抢占式调度 (1) Preemptive Scheduling)

Once a process started its execution, scheduling occurs at the time of a process switches from running state to ready state and from waiting state to ready state is called Preemptive Scheduling.

一旦进程开始执行,调度就在进程从运行状态切换到就绪状态以及从等待状态切换到就绪状态时发生,称为抢先调度。

In this scheduling resources (CPU cycles) are allocated to the process for a short period of time and if some process of higher priority is encountered then the current process can be paused to handle that process.

在这种调度中,资源(CPU周期)会在短时间内分配给该进程,如果遇到某些优先级更高的进程,则可以暂停当前进程以处理该进程。

  • Then resources from the currently running process taken away, and the currently running process is placed back in the ready queue again if it still has remaining CPU burst time. That is we can preempt the control of CPU from one process to another if required. The process remains in a ready queue till it gets the next time slot to get executed.

    然后,如果仍然有剩余的CPU突发时间,则会从当前正在运行的进程中删除资源,并将当前正在运行的进程再次放回到就绪队列中。 也就是说,如果需要,我们可以抢先将CPU的控制从一个进程转移到另一个进程。 该过程将一直处于就绪队列中,直到获得下一个要执行的时隙为止。

  • By implementing this type of scheduling user can work on multiple processes that are it supports multitasking.

    通过实现这种类型的调度,用户可以在支持多任务的多个进程上工作。

  • Examples of Preemptive Scheduling are Round Robin (RR), Shortest Remaining Time First (SRTF), Priority (preemptive version), etc.

    抢占式调度的示例包括循环调度(RR),最短剩余时间优先(SRTF),优先级(抢占版本)等。

2)非抢占式调度 (2) Non-Preemptive Scheduling)

Once a process started its execution, scheduling occurs when a process terminates, or a process switches from running to waiting state.

一旦进程开始执行,调度将在进程终止或进程从运行状态切换到等待状态时进行。

  • When the resources (CPU) are allocated to a process, the process holds the CPU till it gets terminated or it reaches a waiting state.

    当将资源(CPU)分配给进程时,该进程将保持CPU直到其终止或达到等待状态。

  • In non-preemptive scheduling, the scheduler does not interrupt a currently running process in the middle of the execution. But it waits for the process to complete its execution with the CPU, after that it can allocate the CPU to another process.

    在非抢占式调度中,调度程序在执行过程中不会中断当前正在运行的进程。 但是它等待进程完成其与CPU的执行,然后可以将CPU分配给另一个进程。

  • FCFS scheduling is an example of non-preemptive scheduling.

    FCFS调度是非抢占式调度的一个示例。

抢占式和非抢占式调度之间的区别 (Differences between Preemptive and Non-Preemptive Scheduling in OS)

  • In the middle of the execution of a process the execution is interrupted whereas; in non-preemptive scheduling, execution is not interrupted in the middle of execution.

    在执行过程的中间,执行被中断,而; 在非抢占式调度中,在执行过程中不会中断执行。

  • Preemptive Scheduling suffers from the overhead of switching between processes from the ready state to running state, vice-verse, and maintaining the ready queue. On the other hand, non-preemptive scheduling does not suffer from the overhead of switching the process from running state to ready state.

    抢先式调度会遭受从就绪状态到运行状态(反之亦然)之间进行切换以及维护就绪队列的开销。 另一方面,非抢占式调度不会遭受将进程从运行状态切换到就绪状态的开销。

  • When a high priority process arrives frequently in the ready queue then the process with low priority has to wait for a long time, and it may have to starve, in preemptive scheduling. Whereas in the non-preemptive scheduling, if CPU is allocated to the process with larger burst time then the processes with smallest burst time may have to starve.

    当高优先级的进程频繁到达就绪队列时,低优先级的进程必须等待很长时间,并且可能会在抢占式调度中饿死。 而在非抢占式调度中,如果将CPU分配给具有较大突发时间的进程,则突发时间最小的进程可能不得不挨饿。

  • The critical processes are allowed to access CPU whenever they arrive into the read queue. In this way preemptive scheduling is flexible. While non-preemptive scheduling is rigid because if a critical process enters the ready queue the process running CPU not disturbed.

    只要关键进程进入读取队列,就可以访问它们。 这样,抢占式调度是灵活的。 非抢占式调度很严格,因为如果关键进程进入就绪队列,则运行CPU的进程不会受到干扰。

  • The Preemptive Scheduling has to maintain the integrity of shared data so it is cost associative but it is not the case with non-preemptive Scheduling.

    抢先式调度必须维护共享数据的完整性,因此这与成本相关,但非抢先式调度则不是这种情况。

  • The main difference between these two schedules is that in non-preemptive scheduling, the CPU is allocated to the process till it completes its execution or switches from running state to waiting state. Whereas in preemptive scheduling the CPU is allocated to a process for a limited amount of time.

    这两个调度之间的主要区别在于,在非抢占式调度中,CPU被分配给进程,直到它完成执行或从运行状态切换到等待状态。 而在抢占式调度中,CPU将在有限的时间内分配给某个进程。

References:

参考文献:

翻译自: https://www.includehelp.com/operating-systems/preemptive-vs-non-preemptive-scheduling.aspx

抢占式与非抢占式调度

  • 7
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 实验目的 调度的实质是操作系统按照某种预定的策略来分配资源。进程调度的目的是分配CPU资源。由于进程调度程序执行的频率很高,因此调度算法的好坏直接影响到操作系统的性能。本实验的目的是编程模拟实现几种常用的进程调度算法,通过对几组进程分别使用不同的调度算法,计算进程的平均周转时间和平均带权周转时间,比较各种算法的性能优劣。 2. 实验原理 [1]. 进程调度算法描述 进程调度算法包括先来先服务调度算法、最短作业时间优先(抢占抢占)、最高响应比调度算法4种。(每个人必须做FCFS,然后在后面的三种中任选一种,即每个人必须做2种调度算法的模拟。) [2]. 衡量算法性能的参数 计算进程的平均周转时间和平均带权周转时间。 3. 实验内容 (1)编程实现本实验的程序,要求: [1]. 建立进程的进程控制块,进程控制块至少包括: a) 进程名称; b) 进程需要执行时间; c) 进入就绪队列时间; d) 进程执行开始时间 e) 进程执行结束时间 [2]. 编程实现调度算法。 [3]. 进程及相关信息的输入。这些信息可以直接从键盘上输入,也可以从文件读取。 [4]. 时间片与时间流逝的模拟。本实验需要对算法的执行计时,程序应该提供计算时间的方法。一种最简单的方法是使用键盘,比如每敲一次空格代表一个时间片的流逝。另一种方法是使用系统时钟。 [5]. 一组进程序列执行完毕,打印出结果信息。程序需要计算出每个进程的开始执行时间、结束时间、周转时间和带权周转时间,并为整个进程序列计算平均周转时间和平均带权周转时间。程序将计算结果按一定的格显示在计算机屏幕上或输出到文件中。打印出进程调度顺序图。 [6]. 实现数据在磁盘文件上的存取功能。 (2)对下列就绪进程序列分别使用上面的几种算法进行调度,计算每种算法下的平均周转时间和平均带权周转时间。 进程号 到达时间 要求执行时间 0 0 1 1 1 35 2 2 10 3 3 5 4 6 9 5 7 21 6 9 35 7 11 23 8 12 42 9 13 1 10 14 7 11 20 5 12 23 3 13 24 22 14 25 31

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值