process state and transition进程状态和转换

process state and transition

Process State

  • As a process executes, it changes state
    • New:  The process is being created
    • Running:  Instructions are being executed
    • Waiting:  The process is waiting for some event to occur
    • Ready:  The process is waiting to be assigned to a processor
    • Terminated:  The process has finished execution

Waiting:  进程正在等待某些事件发生

Ready::  进程正在等待分配给处理器

Terminated:已终止:  进程已执行完毕

Process Scheduling

  • Process scheduler selects among available processes for next execution on CPU core
  • Goal -- Maximize CPU use, quickly switch processes onto CPU core
  • Maintains scheduling queues of processes
    • Ready queue – set of all processes residing in main memory, ready and waiting to execute
    • Wait queues – set of processes waiting for an event (i.e., I/O)
    • Processes migrate among the various queues

进程调度程序从可用进程中选择下一个在 CPU 内核上执行的进程

目标 -- 最大限度地利用 CPU,快速将进程切换到 CPU 内核上

维护进程调度队列

就绪队列--驻留在主内存中、准备就绪并等待执行的所有进程的集合

等待队列--等待事件(如 I/O)的进程集

进程在不同队列间迁移

  

CPU Switch From Process to Process

  • Information associated with each process (also called task control block)

与每个进程相关的信息(也称为任务控制块)

Context Switch

  • When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch
  • Context of a process represented in the PCB
  • Context-switch time is pure overhead; the system does no useful work while switching
    • The more complex the OS and the PCB è the longer the context switch
  • Time dependent on hardware support
    • Some hardware provides multiple sets of registers per CPU è multiple contexts loaded at once

当 CPU 切换到另一个进程时,系统必须保存旧进程的状态,并通过上下文切换为新进程加载保存的状态

PCB 中表示的进程上下文

上下文切换时间纯属开销;切换时系统不做任何有用的工作

操作系统和 PCB  越复杂,上下文切换的时间就越长

时间取决于硬件支持

某些硬件为每个 CPU 提供多组寄存器  同时加载多个上下文

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值