操作系统 cpu调度_CPU调度| 操作系统

操作系统 cpu调度

调度标准 (Scheduling Criteria)

There are many criteria which have been suggested for comparing the CPU scheduling algorithms. The characteristics which are used for comparison and then used to determine the best algorithms, for this some of the criteria are given below:

已经提出了许多标准来比较CPU调度算法。 下面列出了用于比较然后用于确定最佳算法的特性,其中一些标准如下:

  1. CPU utilization

    CPU利用率

    This is the main task in which we have to keep the CPU as busy as possible. Its known, that CPU utilization may range from 0 to 100 percent, but in a case of the real system it should range from 40 percent for the low-level system to 90 percent for high level used system.

    这是我们必须使CPU尽可能繁忙的主要任务。 众所周知,CPU利用率可能在0到100%的范围内,但是在实际系统中,CPU利用率的范围应该从低级系统的40%到高级系统的90%。

  2. Throughput

    通量

    The number of processes which complete their execution per unit time it is called Throughput. In the case of CPU scheduling, CPU is busy in executing the process, then the work is being done, and the work completed per unit time can also be called as throughput.

    每单位时间完成其执行的进程数称为吞吐量。 在CPU调度的情况下,CPU忙于执行进程,然后完成工作,并且每单位时间完成的工作也称为吞吐量。

  3. Turnaround Time

    周转时间

    This is an amount of time to execute a particular process. Turnaround time is the sum of the periods spent waiting to get into memory, executing on the CPU, waiting in the queue and doing I/O i.e. the interval between the time of submission of a process to the time of completion is the turnaround time.

    这是执行特定过程的时间。 周转时间是等待进入内存,在CPU上执行,在队列中等待以及执行I / O所花费的时间总和,即,从提交进程的时间到完成时间之间的时间间隔就是周转时间。

  4. Waiting time

    等待的时间

    It is an amount of time in which a process has been waiting in the ready queue. It only affects the amount of time that a process spends waiting in the ready queue.

    这是进程在就绪队列中等待的时间。 它仅影响进程在就绪队列中等待所花费的时间。

  5. Response time

    响应时间

    It is an amount of time in which the request was submitted until the first response is produced, not output.

    这是在产生第一个响应(而不是输出)之前提交请求的时间。

In all these cases we need to maximize the CPU utilization and throughput, and to minimize the turnaround time, waiting time, and respond time.

在所有这些情况下,我们都需要最大化CPU利用率和吞吐量,并最小化周转时间,等待时间和响应时间。

调度算法 (Scheduling Algorithms)

Scheduling algorithms deal with the problems of deciding the process which is in the ready queue and need to be allocated in the CPU. There are some algorithms which are discussed below:

调度算法处理确定准备队列中需要在CPU中分配的进程的问题。 下面讨论了一些算法:

1. First-Come First-Served Scheduling

1. First-Come先服务调度

It is a simplest CPU scheduling algorithm. According to this, the process that requests the CPU first is allocated at the CPU first. FCFS is managed with the help of the FIFO queue. When a process enters into a ready queue it will link up at the tail of the queue and when the CPU is free it allocates the process at the head of the queue and by this running, the process is removed from the queue. This is a very simple algorithm for write and to understand.

它是最简单的CPU调度算法。 据此,首先在CPU上分配首先请求CPU的处理。 借助FIFO队列来管理FCFS。 当进程进入就绪队列时,它将在队列的尾部链接,而当CPU空闲时,它将进程分配在队列的开头,并通过此运行将进程从队列中删除。 这是用于编写和理解的非常简单的算法。

Consider the following process that arrives at a time 0 with the CPU burst time in milliseconds.

考虑以下过程,该过程在时间0到达,CPU突发时间以毫秒为单位。

CPU Scheduling in OS

If the process arrive in the order of P1, P2, P3 in order of FCFS then the Gantt chart for this will be:

如果进程按照FCFS的顺序到达P1 , P2 , P3 ,则用于此的甘特图将为:

CPU Scheduling in OS

i.e. average waiting time will be : (0+26+28)/3 = 18. The FCFS scheduling algorithm is non pre-emptive.

即平均等待时间为: (0 + 26 + 28)/ 3 = 18 。 FCFS调度算法是非抢先式的。

2. Shortest Job first scheduling

2.最短的作业优先调度

This is a different approach in need of CPU scheduling. According to this algorithm when the CPU is free, the process will be assigned which will have the smallest next CPU burst. SJF is optimal which means it will provide the average waiting time for a given set of processes. Let us consider an example with the following set of processes, with the length of CPU burst time given in milliseconds.

这是需要CPU调度的另一种方法。 根据该算法,当CPU空闲时,将分配下一个CPU突发最小的进程。 SJF是最佳的,这意味着它将为给定的一组过程提供平均等待时间。 让我们考虑以下一组进程的示例,其中CPU突发时间的长度以毫秒为单位。

CPU Scheduling in OS

Gantt chart for this will be:

甘特图将是:

CPU Scheduling in OS

i.e. average time by using SJF is (0+3+9+16)/4 =7 milliseconds. As SJF is an optimal algorithm which cannot be implemented at the level of short term CPU scheduling as there is no way to know that the length of the next CPU burst.

即使用SJF的平均时间为(0 + 3 + 9 + 16)/ 4 = 7毫秒。 由于SJF是一种最佳算法,无法在短期CPU调度级别上实现,因为无法知道下一个CPU突发的长度。

3. Priority Scheduling

3.优先调度

In this kind of algorithms, a priority is associated with a process and by that CPU will be allocated to the process which will have the highest priority. By this, we can conclude that larger the CPU burst, the lower the priority and vice versa. Let us consider an example with the following set of the process with the length of the CPU burst time given in milliseconds.

在这种算法中,优先级与进程相关联,并由此将CPU分配给优先级最高的进程。 这样,我们可以得出结论,CPU突发越大,优先级越低,反之亦然。 让我们考虑以下过程集的示例,其中以毫秒为单位给出了CPU突发时间的长度。

CPU Scheduling in OS

In this case, the average waiting time is (0+1+6+16+18)/5 =8.2 milliseconds. Priority scheduling can be either pre-emptive or non-pre-emptive. A major problem with the priority scheduling is starvation which means low priority process never executes and the solution to the problem is aging. Aging is a technique of increasing the priority of the process which had wait in the system for a long time.

在这种情况下,平均等待时间为(0 + 1 + 6 + 16 + 18)/ 5 = 8.2毫秒。 优先级调度可以是抢占式或非抢占式。 优先级调度的一个主要问题是饥饿,这意味着永远不会执行低优先级的进程,并且该问题的解决方案是老化。 老化是一种增加已在系统中等待很长时间的进程的优先级的技术。

4. Round Robin Scheduling

4.循环调度

The round robin scheduling algorithm is designed for a time-sharing system in which a small time is defined termed as time quantum. A time quantum is generally from the 10 to 100 milliseconds. For implementing the RR scheduling the CPU scheduler keeps the process for the ready queue and sets a timer to interrupt after the one-time quantum and then the process will be dispatched. If there are m processes in the queue and the time quantum is q then each process gets 1/m of the CPU time and by this, no process will wait for more than (m-1)q time units.

轮循调度算法是为分时系统设计的,在分时系统中,将定义为小时间的时间称为时间量。 时间量通常为10到100毫秒。 为了实现RR调度,CPU调度程序保留准备就绪队列的进程,并将计时器设置为在一次性运行时间后中断,然后将分派该进程。 如果队列中有m个进程,并且时间量为q,则每个进程获得1 / m的CPU时间,这样,没有一个进程将等待超过(m-1)q个时间单位。

翻译自: https://www.includehelp.com/operating-systems/cpu-scheduling.aspx

操作系统 cpu调度

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/543967.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

IOS中KVO模式的解析与应用

最近老翁在项目中多处用到了KVO,深感这种模式的好处。现总结如下: 一、概述 KVO,即:Key-Value Observing,它提供一种机制,当指定的对象的属性被修改后,则对象就会接受到通知。简单的说就是每次指定的被观察…

使用 lambda 实现超强的排序功能

我们在系统开发过程中,对数据排序是很常见的场景。一般来说,我们可以采用两种方式:借助存储系统(SQL、NoSQL、NewSQL 都支持)的排序功能,查询的结果即是排好序的结果查询结果为无序数据,在内存中…

java 的23种设计模式 之单身狗和隔壁老王的故事

2019独角兽企业重金招聘Python工程师标准>>> 觉得代码写的别扭了,回头翻翻java 的23种设计模式。today,额,这么晚了,困了。就弄个最简单的单例模式吧。单例模式:俗称单身狗 package singleton; public class SingleTon { private …

使用python学线性代数_二项式过程| 使用Python的线性代数

使用python学线性代数When we flip a coin, there are two possible outcomes as head or tail. Each outcome has a fixed probability of occurrence. In the case of fair coins, heads and tails each have the same probability of 1/2. In addition, there are cases in …

工作中常见的 6 种设计模式,你用过几种?

前言 哈喽,大家好。平时我们写代码呢,多数情况都是流水线式写代码,基本就可以实现业务逻辑了。如何在写代码中找到乐趣呢,我觉得,最好的方式就是:使用设计模式优化自己的业务代码。今天跟大家聊聊日常工作中…

这12款idea插件,能让你代码飞起来!

前言基本上每个程序员都会写代码,但写代码的速度不尽相同。为什么有些人,一天只能写几百行代码?而有些人,一天可以写几千行代码?有没有办法,可以提升开发效率,在相同的时间内,写出更…

node js 开发网站_使用Node JS开发网站

node js 开发网站You will have your own fully functional website running on "localhost" after going through this article. 阅读完本文后,您将在“ localhost”上运行自己的功能齐全的网站 。 Basic knowledge of JavaScript and HTML is a prereq…

Java:LocalDate / LocalDateTime加减时间

在线API参考:LocalTime (Java Platform SE 8 ) 方法介绍 方法1方法1说明plusYears(long years) minusYears(long years) 返回增加/减少了年数的副本plusMonths(long months) minusMonths(long months)返回增加/减少了月数的副本plusWeeks(long weeks) minusWeeks(…

集合 List 分片的 5 种实现

作者 | 磊哥来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)前些天在实现 MyBatis 批量插入时遇到了一个问题,当批量插入的数据量比较大时,会导致程序执行报错&a…

使用它给 ​xxl-job 添加任务,太爽了

xxl-job是一款非常优秀的任务调度中间件,轻量级、使用简单、支持分布式等优点,让它广泛应用在我们的项目中,解决了不少定时任务的调度问题。我们都知道,在使用过程中需要先到xxl-job的任务调度中心页面上,配置执行器ex…

dubboSPI机制浅谈

2019独角兽企业重金招聘Python工程师标准>>> 本文重点讲述SPI机制,从jdk和dubbo 1、jdk spi机制 2、dubbo spi实现 首先spi是什么? SPI是为某个接口寻找服务实现的机制。为了实现在模块装配的时候能不在…

彻底搞懂 SpringBoot 中的 starter 机制

前言我们都知道,Spring的功能非常强大,但也有些弊端。比如:我们需要手动去配置大量的参数,没有默认值,需要我们管理大量的jar包和它们的依赖。为了提升Spring项目的开发效率,简化一些配置,Sprin…

Java 中验证时间格式的 4 种方法

大家好,今天咱们来讲一下,Java 中如何检查一个字符串是否是合法的日期格式?为什么要检查时间格式?后端接口在接收数据的时候,都需要进行检查。检查全部通过后,才能够执行业务逻辑。对于时间格式&#xff0c…

Redis 实现分布式锁的 7 种方案

前言日常开发中,秒杀下单、抢红包等等业务场景,都需要用到分布式锁。而Redis非常适合作为分布式锁使用。本文将分七个方案展开,跟大家探讨Redis分布式锁的正确使用方式。如果有不正确的地方,欢迎大家指出哈,一起学习一…

css复选框样式_使用CSS样式复选框

css复选框样式Introduction: 介绍: Sometimes we want to develop a website or web page that would contain a form and through that form, we want to get some information from the user. Now that information could be of any type depending on the kind …

javascript对话框_JavaScript中的对话框

javascript对话框JavaScript对话框 (JavaScript Dialog Boxes) Dialog boxes are a great way to provide feedback to the user when they submit a form. In JavaScript, there are three kinds of Dialog boxes, 对话框是向用户提交表单时提供反馈的好方法。 在JavaScript中…

排查死锁的 4 种工具,秀~

作者 | 磊哥来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)死锁(Dead Lock)指的是两个或两个以上的运算单元(进程、线程或协程)&#xf…

MySQL 常见的 9 种优化方法

大家好,我是磊哥!今天给大家分享一些简单好用的数据库优化方式!1、选择最合适的字段属性Mysql是一种关系型数据库,可以很好地支持大数据量的存储,但是一般来说,数据库中的表越小,在它上面执行的…

oracle中dbms_DBMS中的实例和架构

oracle中dbms1)实例 (1) Instances) What is the Instance? If we look towards it in real life, we refer instance as an occurrence of something at a particular moment of time. In Database Management system, there are a lot of changes occurring over time to th…

过滤器和拦截器的 5 个区别!

作者 | 磊哥来源 | Java面试真题解析(ID:aimianshi666)转载请联系授权(微信ID:GG_Stone)过滤器(Filter)和拦截器(Interceptor)都是基于 AOP(Aspec…