操作系统设计与实现(第二章)
合集下载
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
**Process Table (an array of structures)(进程表) each process is a record of this table, and each
record include the state of the process, program counter, stack pointer, and allocation of memory…..; thus, when the process is in ready state, all the info won’t lose.
进程和线程的区别
每个进程项 每个线程项
地址空间 全局变量 打开文件
子进程 定时器
信号和信号处 理程序
统计信息
程序计数器 寄存器 堆栈 状态
允许在同一个进程环境中有多个执行流(线程), 这些流在很大程度上相对独立,但共享相同的地址 空间。
进程用来集合资源,而线程是CPU中调度的实体。
理解进程和程序的区别:
CPU:计算机科学家 程序1:烘制生日蛋糕的食谱 数据:面粉、鸡蛋、糖和香草汁等 对应的进程1:阅读食谱、取来各种原料以及烘制蛋糕的一系列动作的总和。 事件:女儿被蜜蜂螫伤 保存进程1的当前状态:计算机科学家就记录下自己照着食谱做到哪儿了。 程序2:急救手册 数据:药物等 对应的进程2:实施医疗救治(高优先级进程)
多线程的应用(2)
网络蚂蚁(NetAnts)是从因特网下载文件的工具软件,设计特 点如下:
(A)支持HTTP和FTP协议,可同时下载1-5个文件; (B)可随时中止正在下载的任务,任务将自动保存当前状 态; (C)支持拖放,可从浏览器中将链接拖入任务列表; (D)裁剪板自动监视,并可指定将捕获的文件类型; (E)捕获浏览器的动作,当用户在浏览器中单击链接时, 网络蚂蚁将自动激活。
In MINIX, the process management, memory management, and file management are each handled by separate modules within the system ,so the process table is partitioned. Look at the pic:
在交互式系统中,用户可以通过键入命令启动程序。
4. 批处理作业的初始化
在操作系统认为有资源运行另一个作业时,它创建一个新的进程,并 运行其输入队列中的一个作业。
进程的终止
1. 正常退出:多数进程由于完成了它们的工作而终止。
2. 出错退出(自愿):进程发现了严重错误。
3. 严重错误(非自愿):通常是由于程序中的错误所致。例 如,执行了一条非法指令,引用了不存在的内存,或除数 是零。
4. 被其它进程杀死:当一个进程终止时,由该进程所创建的 所有进程也都立即被杀死。
Process hierarchies
Any OS, to support process, it must provide some way to create all the processes needed.
Use fork( ) to create a new process, the father process can create his child processes,0~~~more, and later ,the process tree may appeared.
To these characters , it is easy to analysis the collection of the processes than keep track the rapid switch of CPU
processes
A
B
D
C
C
AB C
DB
D
A
time
One prog count
2.1.3 Threads(线程)
1. Concept to the traditional process, one process just has one control clue(控制流) and one program counter. In modern OS, more and more OS support the multicontrol clue in a process, and we call these control(中断向量)
An interruption ,it relate to each kinds of I/O device (hardware), it contain the address of the interrupt service procedure.
The interrupt procedure store the current variables and info to stacks, and did some works related to it’s recover . Now ,the pre process is stored, and the new one could continue. When it is finished, the old one could be recalled ,and runs smoothly, just nothing had happened. Of course the interrupt must related to their priority. The real procedure is:
Four prog count
Process---Program
Process is an executing program, it has program, input, output, and state. An example:
scientist prepare the cake for his daughter. Recipe: /resipi/ 食谱
在浏览器内设立多个进程,同时请求传输多幅图像,可节 省建立和释放链接的时间。 To small size files, the connection-building needs more time than transporting.
transmitting use .rar .zip than folder.
exchange info among them, but, once more than one processes lead to block
**logically, it have to stop , it will. (wait our input) **logically, it should continue, but it stopped, now,
Running
2. Scheduler picks another process
1 3
2 3. Scheduler picks this process
4. Input becomes available
Blocked
4
Ready
Three States of process, and four transition are there
当蜜蜂螫伤处理完之后,计算机科学家又回来做蛋糕,从他 离开时的那一步继续做下去。
进程的创建
1. 系统初始化
2. (1) 前台进程:同用户交互并替它们完成工作的哪些进程。 3. (2) 后台进程:守护进程,处理网页、打印之类活动的进程。
2.正在运行的一个进程执行了创建进程的系统调用。
3.用户请求创建一个新进程。
the CPU may be occupied by another process. 1. 运行态(Running,在该时刻实际占用处理机)。 2. 就绪态(Ready,可运行,因为其它进程正在运行而暂时
被挂起)。 3. 阻塞态(Blocked,除非某种外部事件发生,否则不能运
行)。
1. Process blocks for input
1 2 3 … … … n-3 n-2 n-1
Scheduler
User process Disk process Terminal process
In this model, we don’t care about the interrupt
2.1.2 Implementation of Processes
操作系统
设计与实现
Chapter 2 Processes
*The importance of process in an operating system
2.1 Introduction to processes *common Parallelism==Pseudoparallelism *It is the cpu rapid switching back and forth *multiprocessor is the real parallelism *people design a model , sequential processes 顺序进程
The real application of threads model from the application to show it’s importance to OS
多线程的应用(1)
explorer netscape(网络浏览器) 许多Web页面都包含有多幅很小的图像。 site: the images folder lies D:\site\images process: build up one connection threads: build up more connection
A
B
To A: when sever is busy , it will stopped, the writing will stopped. save the destination to ….
To B: when server is busy, other threads will still try.. the writing won’t stopped. use flashget netant
**** A Process is an activity of some kind, It has a program ,input, output, and a state, A single processor may be shared among several processes, with some scheduling algorithm being used to determine when to stop work on one process and service a different one.
2.1.1 The process model
Characters: * All the runnable software are organized into a number of sequential
processes; (in this chapter we called it processes) * The process is an executing program; •The process include the values of the all the program counter, registers,and variables;(进程包括程序计数器、 寄存器和变量的当前值。)
In Minix, the root is init, and it works in this way: read info, create terminal, start program, NFS,
SMTP , WWW,FTP……
Process States
进程之间经常需要交互、通信以及和其他进程同步。 For Communication between processes
record include the state of the process, program counter, stack pointer, and allocation of memory…..; thus, when the process is in ready state, all the info won’t lose.
进程和线程的区别
每个进程项 每个线程项
地址空间 全局变量 打开文件
子进程 定时器
信号和信号处 理程序
统计信息
程序计数器 寄存器 堆栈 状态
允许在同一个进程环境中有多个执行流(线程), 这些流在很大程度上相对独立,但共享相同的地址 空间。
进程用来集合资源,而线程是CPU中调度的实体。
理解进程和程序的区别:
CPU:计算机科学家 程序1:烘制生日蛋糕的食谱 数据:面粉、鸡蛋、糖和香草汁等 对应的进程1:阅读食谱、取来各种原料以及烘制蛋糕的一系列动作的总和。 事件:女儿被蜜蜂螫伤 保存进程1的当前状态:计算机科学家就记录下自己照着食谱做到哪儿了。 程序2:急救手册 数据:药物等 对应的进程2:实施医疗救治(高优先级进程)
多线程的应用(2)
网络蚂蚁(NetAnts)是从因特网下载文件的工具软件,设计特 点如下:
(A)支持HTTP和FTP协议,可同时下载1-5个文件; (B)可随时中止正在下载的任务,任务将自动保存当前状 态; (C)支持拖放,可从浏览器中将链接拖入任务列表; (D)裁剪板自动监视,并可指定将捕获的文件类型; (E)捕获浏览器的动作,当用户在浏览器中单击链接时, 网络蚂蚁将自动激活。
In MINIX, the process management, memory management, and file management are each handled by separate modules within the system ,so the process table is partitioned. Look at the pic:
在交互式系统中,用户可以通过键入命令启动程序。
4. 批处理作业的初始化
在操作系统认为有资源运行另一个作业时,它创建一个新的进程,并 运行其输入队列中的一个作业。
进程的终止
1. 正常退出:多数进程由于完成了它们的工作而终止。
2. 出错退出(自愿):进程发现了严重错误。
3. 严重错误(非自愿):通常是由于程序中的错误所致。例 如,执行了一条非法指令,引用了不存在的内存,或除数 是零。
4. 被其它进程杀死:当一个进程终止时,由该进程所创建的 所有进程也都立即被杀死。
Process hierarchies
Any OS, to support process, it must provide some way to create all the processes needed.
Use fork( ) to create a new process, the father process can create his child processes,0~~~more, and later ,the process tree may appeared.
To these characters , it is easy to analysis the collection of the processes than keep track the rapid switch of CPU
processes
A
B
D
C
C
AB C
DB
D
A
time
One prog count
2.1.3 Threads(线程)
1. Concept to the traditional process, one process just has one control clue(控制流) and one program counter. In modern OS, more and more OS support the multicontrol clue in a process, and we call these control(中断向量)
An interruption ,it relate to each kinds of I/O device (hardware), it contain the address of the interrupt service procedure.
The interrupt procedure store the current variables and info to stacks, and did some works related to it’s recover . Now ,the pre process is stored, and the new one could continue. When it is finished, the old one could be recalled ,and runs smoothly, just nothing had happened. Of course the interrupt must related to their priority. The real procedure is:
Four prog count
Process---Program
Process is an executing program, it has program, input, output, and state. An example:
scientist prepare the cake for his daughter. Recipe: /resipi/ 食谱
在浏览器内设立多个进程,同时请求传输多幅图像,可节 省建立和释放链接的时间。 To small size files, the connection-building needs more time than transporting.
transmitting use .rar .zip than folder.
exchange info among them, but, once more than one processes lead to block
**logically, it have to stop , it will. (wait our input) **logically, it should continue, but it stopped, now,
Running
2. Scheduler picks another process
1 3
2 3. Scheduler picks this process
4. Input becomes available
Blocked
4
Ready
Three States of process, and four transition are there
当蜜蜂螫伤处理完之后,计算机科学家又回来做蛋糕,从他 离开时的那一步继续做下去。
进程的创建
1. 系统初始化
2. (1) 前台进程:同用户交互并替它们完成工作的哪些进程。 3. (2) 后台进程:守护进程,处理网页、打印之类活动的进程。
2.正在运行的一个进程执行了创建进程的系统调用。
3.用户请求创建一个新进程。
the CPU may be occupied by another process. 1. 运行态(Running,在该时刻实际占用处理机)。 2. 就绪态(Ready,可运行,因为其它进程正在运行而暂时
被挂起)。 3. 阻塞态(Blocked,除非某种外部事件发生,否则不能运
行)。
1. Process blocks for input
1 2 3 … … … n-3 n-2 n-1
Scheduler
User process Disk process Terminal process
In this model, we don’t care about the interrupt
2.1.2 Implementation of Processes
操作系统
设计与实现
Chapter 2 Processes
*The importance of process in an operating system
2.1 Introduction to processes *common Parallelism==Pseudoparallelism *It is the cpu rapid switching back and forth *multiprocessor is the real parallelism *people design a model , sequential processes 顺序进程
The real application of threads model from the application to show it’s importance to OS
多线程的应用(1)
explorer netscape(网络浏览器) 许多Web页面都包含有多幅很小的图像。 site: the images folder lies D:\site\images process: build up one connection threads: build up more connection
A
B
To A: when sever is busy , it will stopped, the writing will stopped. save the destination to ….
To B: when server is busy, other threads will still try.. the writing won’t stopped. use flashget netant
**** A Process is an activity of some kind, It has a program ,input, output, and a state, A single processor may be shared among several processes, with some scheduling algorithm being used to determine when to stop work on one process and service a different one.
2.1.1 The process model
Characters: * All the runnable software are organized into a number of sequential
processes; (in this chapter we called it processes) * The process is an executing program; •The process include the values of the all the program counter, registers,and variables;(进程包括程序计数器、 寄存器和变量的当前值。)
In Minix, the root is init, and it works in this way: read info, create terminal, start program, NFS,
SMTP , WWW,FTP……
Process States
进程之间经常需要交互、通信以及和其他进程同步。 For Communication between processes