操作系统抢占式优先级调度_操作系统中的优先级调度(非抢先)

操作系统中的非抢占式优先级调度算法依赖于进程的优先级而非突发时间来决定执行顺序。当进程开始执行后,即使有更高优先级的进程到达,也不会被抢占,直至该进程执行完毕。例如,4个进程P1, P2, P3, P4根据优先级顺序执行,低优先级数字表示高优先级。在第4个时间单位P1完成后,P2, P3, P4按照优先级依次执行。" 130546130,9803657,使用Python与OpenCV创建GIF动图,"['Python', '计算机视觉', 'OpenCV']
摘要由CSDN通过智能技术生成

操作系统抢占式优先级调度

Priority scheduling is a type of scheduling algorithm used by the operating system to schedule the processes for execution. The priority scheduling has both the preemptive mode of scheduling and the non-preemptive mode of scheduling. Here, we will discuss the non-preemptive priority scheduling algorithm.

优先级调度是操作系统用来调度要执行的进程的调度算法。 优先级调度既有抢占式调度又有非抢占式调度。 在这里, 我们将讨论非抢占式优先级调度算法

As the name suggests, the scheduling depends upon the priority of the processes rather than its burst time. So, the processes, in this case, must also have the priority number in its details on the basis of which the OS will schedule it.

顾名思义,调度取决于进程的优先级,而不是突发时间。 因此,在这种情况下,进程还必须在其详细信息中具有优先级号,操作系统将根据该优先级号对其进行调度。

For example, suppose we have 4 processes: P1, P2, P3 and P4 and they enter the CPU as follows:

例如,假设我们有4个进程: P1P2P3P4 ,它们按如下方式进入CPU:

Note: Here, lower the priority number, higher is the priority.

注意:此处,优先级数字越低,优先级越高。

priority scheduling in OS

As per the non-preemptive priority scheduling, the processes will be executed as follows:

根据非抢先优先级调度 ,将按以下方式执行过程:

Gant Chart:

甘特图:

priority scheduling in OS

Explanation:

说明:

  • There is only P1 available at time 0, so it will be executed first irrespective of the priority, and it cannot be preempted in between before its completion.

    在时间0只有P1可用,因此无论优先级如何都将首先执行它,并且在完成之前不能抢占它。

  • When it is completed at 4th-time unit, we have all P2, P3, and P4 available. So, they are executed according to their priorities.

    当以 4 单位完成时,我们将拥有所有P2P3P4 。 因此,将根据优先级执行它们。

priority scheduling in OS
    Total Turn Around Time = 4 + 7 + 9 + 2
                = 22 milliseconds
    Average Turn Around Time= Total Turn Around Time / Total No. of Processes
                = 22 / 4
                = 5.5 milliseconds

    Total Waiting Time = 0 + 5 + 6 + 0
                = 11 milliseconds
    Average Waiting Time = Total Waiting Time / Total No. of Processes
                = 11 / 4
                = 2.75 milliseconds


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

操作系统抢占式优先级调度

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值