操作系统设计与实现(第二章)

上传人:ji****72 文档编号:51712575 上传时间:2018-08-16 格式:PPT 页数:113 大小:766KB
返回 下载 相关 举报
操作系统设计与实现(第二章)_第1页
第1页 / 共113页
操作系统设计与实现(第二章)_第2页
第2页 / 共113页
操作系统设计与实现(第二章)_第3页
第3页 / 共113页
操作系统设计与实现(第二章)_第4页
第4页 / 共113页
操作系统设计与实现(第二章)_第5页
第5页 / 共113页
点击查看更多>>
资源描述

《操作系统设计与实现(第二章)》由会员分享,可在线阅读,更多相关《操作系统设计与实现(第二章)(113页珍藏版)》请在金锄头文库上搜索。

1、 操作系统设计与实现Chapter 2 Processes*The importance of process in an operating system*The importance of process in an operating system2.1 Introduction to processes *common Parallelism=Pseudoparallelism *It is the cpu rapid switching back and forth *multiprocessor is the real parallelism *people design a mo

2、del ,sequential processes 顺序进程2.1.1 The process modelCharacters:Characters: * All the * All the runnablerunnable software are organized into a software are organized into a number of sequential number of sequential processes; (in this chapter we called it processes) processes; (in this chapter we ca

3、lled it processes) * The process is an executing program;* The process is an executing program; The process include the values of the all the The process include the values of the all the program counter, registersprogram counter, registers,and variables;(and variables;(进程包括进程包括 程序计数器、寄存器和变量的当前值。)程序

4、计数器、寄存器和变量的当前值。)To these characters , it is easy to analysis the To these characters , it is easy to analysis the collection of the processes than keep track the rapid collection of the processes than keep track the rapid switch of CPUswitch of CPUABCDOne One progprog count countABCDFour Four progpr

5、og count countABCDtimetimeprocessesprocessesProcess-ProgramProcess is an executing program, it has program, Process is an executing program, it has program, input, output, and state.input, output, and state. An example: An example: scientist prepare the cake for his daughter.scientist prepare the ca

6、ke for his daughter. Recipe: /Recipe: /resipiresipi/ / 食谱食谱* * A Process is an activity of some kind, It has a A Process is an activity of some kind, It has a program ,input, output, and a state, A single program ,input, output, and a state, A single processor may be shared among several processes,

7、processor may be shared among several processes, with some scheduling algorithm being used to with some scheduling algorithm being used to determine when to stop work on one process and determine when to stop work on one process and service a different one.service a different one.理解进程和程序的区别: CPU:计算机

8、科学家 程序1:烘制生日蛋糕的食谱数据:面粉、鸡蛋、糖和香草汁等 对应的进程1:阅读食谱、取来各种原料以及烘制蛋糕的一系列动作的总和。事件:女儿被蜜蜂螫伤 保存进程1的当前状态:计算机科学家就记录下自己照着食谱做到哪儿了。 程序2:急救手册数据:药物等 对应的进程2:实施医疗救治(高优先级进程)当蜜蜂螫伤处理完之后,计算机科学家又回来做蛋糕,从 他离开时的那一步继续做下去。进程的创建系统初始化(1) 前台进程:同用户交互并替它们完成工作的哪些进程。(2) 后台进程:守护进程,处理网页、打印之类活动的进程。2.正在运行的一个进程执行了创建进程的系统调用。3.用户请求创建一个新进程。在交互式系统中

9、,用户可以通过键入命令启动程序。4. 批处理作业的初始化在操作系统认为有资源运行另一个作业时,它创建一个新的进程, 并运行其输入队列中的一个作业。进程的终止正常退出:多数进程由于完成了它们的工作而终止。出错退出(自愿):进程发现了严重错误。严重错误(非自愿):通常是由于程序中的错误所致。 例如,执行了一条非法指令,引用了不存在的内存,或除 数是零。被其它进程杀死:当一个进程终止时,由该进程所创建 的所有进程也都立即被杀死。Process hierarchiesAny OS, to support process, it must provide some Any OS, to support

10、process, it must provide some way to create all the processes needed.way to create all the processes needed.Use fork( ) Use fork( ) to create a new process, the father to create a new process, the father process can create his child processes,0more, and process can create his child processes,0more,

11、and later ,the process tree may appeared.later ,the process tree may appeared.In In MinixMinix, the root is init, and it works in this way:, the root is init, and it works in this way: read info, create terminal, start program, NFS, read info, create terminal, start program, NFS, SMTP , WWW,FTPSMTP

12、, WWW,FTPProcess States进程之间经常需要交互、通信以及和其他进程同步。进程之间经常需要交互、通信以及和其他进程同步。 For Communication between processesFor Communication between processes exchange info among them, but, once more than exchange info among them, but, once more than one processes one processes lead to block lead to block*logically,

13、it have to stop , it will. (wait our input)*logically, it have to stop , it will. (wait our input) *logically, it should continue, but it stopped, now,*logically, it should continue, but it stopped, now,the CPU may be occupied by another process. the CPU may be occupied by another process. 运行态(Runni

14、ng,在该时刻实际占用处理机)。 就绪态(Ready,可运行,因为其它进程正在运行而暂 时被挂起)。 阻塞态(Blocked,除非某种外部事件发生,否则不能运 行)。RunningBlockedReady12 341. Process blocks for input1. Process blocks for input2. Scheduler picks another 2. Scheduler picks another processprocess3. Scheduler picks this process3. Scheduler picks this process4. Input

15、becomes available4. Input becomes availableThree States of process, and four transition are thereThree States of process, and four transition are there123n-3 n-2n-1SchedulerSchedulerUser processUser processDisk processDisk processTerminal processTerminal processIn this model, we dont care In this mo

16、del, we dont care about the interruptabout the interrupt2.1.2 Implementation of Processes*Process Table *Process Table (an array of structures)(an array of structures)(进程表)(进程表) each process is a record of this table, and each each process is a record of this table, and each record include the state of the process, program record include the state of the process, program counter, stack p

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 综合/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号