cpu都有什么调度算法_什么是CPU调度?

cpu都有什么调度算法

CPU scheduling is a process which allows one process to use the CPU while the execution of another process is on hold(in waiting state) due to unavailability of any resource like I/O etc, thereby making full use of CPU. The aim of CPU scheduling is to make the system efficient, fast and fair.

CPU调度是一种进程,由于诸如I / O等任何资源的不可用,该进程允许一个进程使用CPU,而另一个进程的执行处于暂停状态(处于等待状态),从而充分利用CPU。 CPU调度的目的是使系统高效,快速且公平。

Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The selection process is carried out by the short-term scheduler (or CPU scheduler). The scheduler selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them.

每当CPU空闲时,操作系统都必须在就绪队列中选择要执行的进程之一。 选择过程由短期调度程序(或CPU调度程序)执行。 调度程序从内存中准备执行的进程中进行选择,并将CPU分配给其中一个。

CPU调度:调度程序 (CPU Scheduling: Dispatcher)

Another component involved in the CPU scheduling function is the Dispatcher. The dispatcher is the module that gives control of the CPU to the process selected by the short-term scheduler. This function involves:

CPU调度功能中涉及的另一个组件是Dispatcher 。 调度程序是使CPU控制由短期调度程序选择的进程的模块。 该功能涉及:

  • Switching context

    切换上下文

  • Switching to user mode

    切换到用户模式

  • Jumping to the proper location in the user program to restart that program from where it left last time.

    跳到用户程序中的正确位置以从上次离开的位置重新启动该程序。

The dispatcher should be as fast as possible, given that it is invoked during every process switch. The time taken by the dispatcher to stop one process and start another process is known as the Dispatch Latency. Dispatch Latency can be explained using the below figure:

鉴于在每个过程切换期间都会调用调度程序,因此调度程序应尽可能快。 调度程序停止一个进程并启动另一个进程所花费的时间称为“ 调度延迟” 。 可以使用下图解释调度延迟。

Dispatch latency of Process Dispatcher

CPU调度的类型 (Types of CPU Scheduling)

CPU scheduling decisions may take place under the following four circumstances:

CPU调度决策可能在以下四种情况下发生:

  1. When a process switches from the running state to the waiting state(for I/O request or invocation of wait for the termination of one of the child processes).

    当进程从运行状态切换到等待状态时(用于I / O请求或调用等待以终止子进程之一)。

  2. When a process switches from the running state to the ready state (for example, when an interrupt occurs).

    当进程从运行状态切换到就绪状态时(例如,发生中断时)。

  3. When a process switches from the waiting state to the ready state(for example, completion of I/O).

    当进程从等待状态切换到就绪状态时(例如,I / O完成)。

  4. When a process terminates.

    当进程终止时

In circumstances 1 and 4, there is no choice in terms of scheduling. A new process(if one exists in the ready queue) must be selected for execution. There is a choice, however in circumstances 2 and 3.

在情况1和4中,就调度而言别无选择。 必须选择一个新进程(如果就绪队列中存在一个进程)来执行。 但是,在情况2和3下可以选择。

When Scheduling takes place only under circumstances 1 and 4, we say the scheduling scheme is non-preemptive; otherwise the scheduling scheme is preemptive.

当仅在情况1和4下进行调度时,我们说调度方案是非抢占式 ; 否则,调度方案是抢占式的

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

Under non-preemptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.

在非抢占式调度下,一旦将CPU分配给某个进程,该进程将保留CPU,直到通过终止或切换到等待状态释放CPU。

This scheduling method is used by the Microsoft Windows 3.1 and by the Apple Macintosh operating systems.

Microsoft Windows 3.1和Apple Macintosh操作系统使用此调度方法。

It is the only method that can be used on certain hardware platforms, because It does not require the special hardware(for example: a timer) needed for preemptive scheduling.

这是可以在某些硬件平台上使用的唯一方法,因为它不需要抢先式调度所需的特殊硬件(例如:计时器)。

抢占式调度 (Preemptive Scheduling)

In this type of Scheduling, the tasks are usually assigned with priorities. At times it is necessary to run a certain task that has a higher priority before another task although it is running. Therefore, the running task is interrupted for some time and resumed later when the priority task has finished its execution.

在这种类型的计划中,通常为任务分配优先级。 有时有必要在运行另一个任务之前先运行优先级更高的某个任务。 因此,正在运行的任务会中断一段时间,并在优先任务完成执行后再继续执行。

CPU调度:调度标准 (CPU Scheduling: Scheduling Criteria)

There are many different criterias to check when considering the "best" scheduling algorithm, they are:

在考虑“最佳”调度算法时,有许多不同的标准要检查,它们是:

CPU利用率 (CPU Utilization)

To make out the best use of CPU and not to waste any CPU cycle, CPU would be working most of the time(Ideally 100% of the time). Considering a real system, CPU usage should range from 40% (lightly loaded) to 90% (heavily loaded.)

为了充分利用CPU而不浪费任何CPU周期,CPU大部分时间都处于工作状态(理想情况下为100%的时间)。 考虑到实际系统,CPU使用率应介于40%(轻载)到90%(重载)之间。

通量 (Throughput)

It is the total number of processes completed per unit time or rather say total amount of work done in a unit of time. This may range from 10/second to 1/hour depending on the specific processes.

它是每单位时间完成的过程总数,或者说单位时间内完成的工作总量。 根据特定的过程,范围可能从10 /秒到1 /小时。

周转时间 (Turnaround Time)

It is the amount of time taken to execute a particular process, i.e. The interval from time of submission of the process to the time of completion of the process(Wall clock time).

它是执行特定过程所花费的时间,即从提交过程到完成过程的时间(挂钟时间)。

等待的时间 (Waiting Time)

The sum of the periods spent waiting in the ready queue amount of time a process has been waiting in the ready queue to acquire get control on the CPU.

在就绪队列中等待一个进程已在就绪队列中等待以获取CPU上的控制权所花费的时间总和。

平均负载 (Load Average)

It is the average number of processes residing in the ready queue waiting for their turn to get into the CPU.

它是就绪队列中等待轮流进入CPU的平均进程数。

响应时间 (Response Time)

Amount of time it takes from when a request was submitted until the first response is produced. Remember, it is the time till the first response and not the completion of process execution(final response).

从提交请求到生成第一个响应所花费的时间。 请记住,这是直到第一个响应而不是流程执行(最终响应)完成的时间。

In general CPU utilization and Throughput are maximized and other factors are reduced for proper optimization.

通常,CPU利用率和吞吐量会最大化,而其他因素也会减少,以进行适当的优化。

调度算法 (Scheduling Algorithms)

To decide which process to execute first and which process to execute last to achieve maximum CPU utilisation, computer scientists have defined some algorithms, they are:

为了确定首先执行哪个进程以及最后执行哪个进程以最大程度地利用CPU,计算机科学家定义了一些算法,它们是:

  1. First Come First Serve(FCFS) Scheduling

    先来先服务(FCFS)调度

  2. Shortest-Job-First(SJF) Scheduling

    最短工作优先(SJF)调度

  3. Priority Scheduling

    优先排程

  4. Round Robin(RR) Scheduling

    循环调度(RR)调度

  5. Multilevel Queue Scheduling

    多级队列调度

  6. Multilevel Feedback Queue Scheduling

    多级反馈队列调度

We will be discussing all the scheduling algorithms, one by one, in detail in the next tutorials.

在接下来的教程中,我们将详细讨论所有调度算法。

翻译自: https://www.studytonight.com/operating-system/cpu-scheduling

cpu都有什么调度算法

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值