Chapter 6 CPU Scheduling

  1. CPU scheduler
    • CPU scheduling decisions may take place under the following circumstances
      • Switches from running to waiting state.(Nonpreemptive)
      • Switches from running to ready state.(Preemptive)
      • Switches from waiting to ready.(Preemptive)
      • Terminates.(Nonpreemptive)
    • 非抢占方式:使某进程一直执行,直到该进程完成或发生某事件而被阻塞时,才把处理机分配给其他进程
      • 优点
        • 实现简单
        • 系统开销小
        • 适用于大多数批处理系统环境
      • 缺点
        • 难以满足紧急任务的要求
        • 不适用于实时、分时系统要求
    • 抢占方式:允许调度程序根据某个原则,取停止某个正在执行的进程,将处理机重新分配给另一个进程
      • 抢占原则
        • 时间片原则:适用于分时系统
        • 优先权原则
        • 短作业优先原则
  2. Dispatcher: dispatch the control of CPU to the process selected by short-term scheduler
    • Switching context
    • Switching to user mode
    • Jumping to the proper location in the user program to restart that program
  3. Scheduling criteria
    • CPU utilization: keep the CPU as busy as possible
    • Throughput
    • Turnaround time: the interval from submission to completion
    • Waiting time
    • Response time
  4. Scheduling algorithm
    • FCFS
      • 最简单的调度算法
      • 非抢占
      • 有利于长作业,不利于短作业;有利于CPU繁忙型,不利于I/O繁忙型
    • SJF
      • Two schemes
        • Nonpreemptive: once CPU given to process, it cannot be preempted until completing its CPU burst
        • Preemptive
      • SJF is optimal(As for waiting time)
      • Can only estimate the length
        • Can be done by using the length of previous CPU bursts, using exponential averaging
        • 一般情况下SJF比FCFS效率高一些,但实现相对要困难些
        • 可能会产生饥饿
    • Priority scheduling
      • Preemptive
      • Nonpreemptive
      • 静态优先权在进程创建时确定,并在整个生命期中保持不变
        • 可能会产生饥饿
        • Solution
          • Aging: as time progresses, increase the priority of the process
      • 动态优先权
        • 因素
          • 进程的等待时间
          • 已使用处理机的时间
          • 资源使用情况
    • Round robin(RR)
      • Typically, higher average turnaround than SJF, but better response
      • 一组进程的平均周转时间并不一定随着时间片的增大而降低。一般来说,如果大多数(80%)进程能在一个时间片内完成,就会改善平均周转时间
    • Multilevel queue
      • Each queue has its own scheduling algorithm
        • Foreground --- RR
        • Background --- FCFS
    • Multilevel feedback queue
    • Highest response ratio next(HRRN)
      • 基于优先权算法
      • 在每次选择作业投入运行时,先计算后备作业队列中每个作业的响应比RP,然后选择其值最大的作业投入运行
      • RP值定义为:
      • RP=(已等待时间+要求运行时间)/要求运行时间 = 1+已等待时间/要求运行时间
      • HRRN算法实际上是FCFS和SJF的折衷
      • 优点:
        • 等待时间相同,则SJF
        • 要求的服务时间相同,则FCFS
        • 长作业的优先级随着等待时间的增加而提高,不会出现得不到响应的情况。
      • 缺点:
        • 作业调度程序要统计作业的等待时间,作浮点运算(这是系统程序最忌讳的)浪费大量的计算时间
  5. Multiple-processor scheduling
    • Load sharing --- 设置一个公共的就绪队列
  6. Real-time scheduling
    • First, the system must have priority scheduling, and real-time processes must have the highest priority;
    • Second, the dispatch lantency must be small
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值