Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3 Process Description and Control

Similar presentations


Presentation on theme: "Chapter 3 Process Description and Control"— Presentation transcript:

1 Chapter 3 Process Description and Control
Operating System Chapter 3 Process Description and Control

2 Chap3 Process Description and Control
3.1 What is a Process 3.2 Process States 3.3 Process Description 3.4 Process Control 3.5 Execution of the Operating System

3 3.1 What is a Process 3.1.1 Background 3.1.2 Processes and PCBs

4 3.1.1 Background(1/1) Requirements of an Operating System
Interleave(交替) the execution of multiple jobs/tasks/道/programs/processes to maximize processor utilization while providing reasonable response time(响应 时间) Allocate resources to processes Support interprocess communication(进程 间通信) and user creation of processes

5 3.1 What is a Process 3.1.1 Background 3.1.2 Processes and PCBs

6 3.1.2 Processes and PCBs(1/4) A program in execution
An instance of a program running on a computer The entity that can be assigned to and executed on a processor A unit of activity characterized by: the execution of a sequence of instructions a current state an associated set of system resources ......

7 3.1.2 Processes and PCBs(2/4) (Review) Process构成:Consists of three components An executable program /code Associated data needed by the program Execution context of the program (the core) All information the operating system needs to manage the process Hardware Software

8 3.1.2 Processes and PCBs(3/4) Process Elements Identifier State
Priority Program counter Memory pointers Context data I/O status information Accounting information

9 3.1.2 Processes and PCBs(4/4) Process Control Block(进程控制块 PCB)
Contains the process elements Created and manage by the operating system Allows support for multiple processes 进程控制块-PCB,又称进程描述符或进程属性 操作用于管理控制进程的一个专门的数据结构 记录进程的各种属性,描述进程的动态变化过程 PCB是系统感知进程存在的唯一标志:进程与PCB一一对应

10 Chap3 Process Description and Control
3.1 What is a Process 3.2 Process States 3.3 Process Description 3.4 Process Control 3.5 Execution of the Operating System

11 3.2 Process States 3.2.1 Trace of the Process
3.2.2 A Two-State Process Model 3.2.3 The Creation and Termination of Processes 3.2.4 A Five-State Model 3.2.5 Suspended Process

12 3.2.1 Trace of the Process(1/4)
Trace of Process(进程轨迹) Sequence of instruction that execute for a process Dispatcher(调度器) switches the processor from one process to another

13 3.2.1 Trace of the Process(2/4)
Example Execution

14 3.2.1 Trace of the Process(3/4)

15 3.2.1 Trace of the Process(4/4)

16 3.2 Process States 3.2.1 Trace of the Process
3.2.2 A Two-State Process Model 3.2.3 The Creation and Termination of Processes 3.2.4 A Five-State Model 3.2.5 Suspended Process

17 3.2.2 A Two-State Process Model(1/2)
两状态进程模型 Process may be in one of two states Running:chen进程占用CPU Not-running:进程不占CPU

18 3.2.2 A Two-State Process Model(2/2)
Not-Running Process in a Queue

19 3.2 Process States 3.2.1 Trace of the Process
3.2.2 A Two-State Process Model 3.2.3 The Creation and Termination of Processes 3.2.4 A Five-State Model 3.2.5 Suspended Process

20 3.2.3 The Creation and Termination of Processes(1/3)
Process Creation page113 process spawning 进程派生

21 3.2.3 The Creation and Termination of Processes(2/3)
Process Termination

22 3.2.3 The Creation and Termination of Processes(3/3)
Process Termination

23 3.2 Process States 3.2.1 Trace of the Process
3.2.2 A Two-State Process Model 3.2.3 The Creation and Termination of Processes 3.2.4 A Five-State Model 3.2.5 Suspended Process

24 3.2.4 A Five-State Model(1/7) Limit of Two-State Process Model
Not-running ready to execute waiting for I/O (blocked) Dispatcher cannot just select the process that has been in the queue the longest because it may be blocked

25 3.2.4 A Five-State Model(2/7) Process State New(新建态) Ready(就绪态)
Running(运行态) Blocked(阻塞态) Exit(退出态) runing:占用处理机(单处理机环境中,某一时刻仅一个进程占用处理机) ready:准备执行 blocked:等待某事件发生才能执行,如等待I/O完成等 new:进程已经创建,但未被OS接纳为可执行进程,并且程序还在辅存,PCB在内存 exit:因停止或取消,被OS从执行状态释放

26 3.2.4 A Five-State Model(3/7)

27 3.2.4 A Five-State Model(4/7)

28 3.2.4 A Five-State Model(5/7) Using Two Queues

29 3.2.4 A Five-State Model(6/7) Multiple Blocked Queues

30 3.2.4 A Five-State Model(7/7)

31 3.2 Process States 3.2.1 Trace of the Process
3.2.2 A Two-State Process Model 3.2.3 The Creation and Termination of Processes 3.2.4 A Five-State Model 3.2.5 Suspended Process

32 3.2.5 Suspended Process(1/4) 被挂起的进程 Why? How? Result?
Processor is faster than I/O so all processes could be waiting for I/O How? Swap these processes to disk to free up more memory Result? Blocked state becomes suspend state when swapped to disk

33 3.2.5 Suspended Process(2/4)

34 3.2.5 Suspended Process(3/4) Two new states Blocked/Suspend
Ready/Suspend

35 3.2.5 Suspended Process(4/4) Reasons for Process Suspension

36 Chap3 Process Description and Control
3.1 What is a Process 3.2 Process States 3.3 Process Description 3.4 Process Control 3.5 Execution of the Operating System

37 3.3 Process Description 3.3.1 Processes and Resources
3.3.2 OS Control Structures 3.3.3 Process Control Structures

38 3.3.1 Processes and Resources(1/2)

39 3.3.1 Processes and Resources(2/2)

40 3.3 Process Description 3.3.1 Processes and Resources
3.3.2 OS Control Structures 3.3.3 Process Control Structures

41 3.3.2 OS Control Structures(1/7)
OS Control Tables Memory tables I/O tables File tables Process table

42 3.3.2 OS Control Structures(2/7)
Memory Tables Allocation of main memory to processes (分 配给进程的主存) Allocation of secondary memory to processes (分配给进程的辅存) Protection attributes for access to shared memory regions(共享内存区域的保护属性) Information needed to manage virtual memory(虚拟内存的管理信息)

43 3.3.2 OS Control Structures(3/7)
I/O Tables I/O device is available or assigned(分配状态) Status of I/O operation Location in main memory being used as the source or destination of the I/O transfer (数 据传送的源和目的地址)

44 3.3.2 OS Control Structures(4/7)
File Tables Existence of files Location on secondary memory Current Status Attributes

45 3.3.2 OS Control Structures(5/7)
Process table Every entry is a PCB(description of a process image)

46 3.3.2 OS Control Structures(6/7)
Process Image A process image is just a process's allocated space in virtual memory Collection of program, data, stack, attributes

47 3.3.2 OS Control Structures(7/7)
Process Image (P132)

48 3.3 Process Description 3.3.1 Processes and Resources
3.3.2 Operating System Control Structures 3.3.3 Process Control Structures

49 3.3.3 Process Control Structures(1/10)
Process Control Block Process Identification Processor State Information User-Visible Registers Control and Status Registers Stack Pointers Process Control information Scheduling and State Information Data Structuring (link information) Interprocess Communication Process Privileges Memory Management Resource Ownership and Utilization

50 3.3.3 Process Control Structures(2/10)
Process identification Process Identifiers(标志号) Numeric identifiers that may be stored with the process control block include Identifier of this process (进程标志) Identifier of the process that created this process (父进程标志) User identifier(用户标志)

51 3.3.3 Process Control Structures(3/10)
Processor State Information User-Visible Registers A user-visible register is one that may be referenced by means of the machine language that the processor executes while in user mode. Typically, there are from 8 to 32 of these registers, although some RISC implementations have over 100.

52 3.3.3 Process Control Structures(4/10)
Processor State Information Control and Status Registers:These are a variety of processor registers that are employed to control the operation of the processor. These include Program counter: Contains the address of the next instruction to be fetched Condition codes: Result of the most recent arithmetic or logical operation (e.g., sign, zero, carry, equal, overflow) Status information: Includes interrupt enabled/disabled flags, execution mode

53 3.3.3 Process Control Structures(5/10)
Processor State Information Stack Pointers Each process has one or more last-in-first-out (LIFO) system stacks associated with it. A stack is used to store parameters and calling addresses for procedure and system calls(活动记录). The stack pointer(栈指针) points to the top of the stack. The frame pointer(帧指针) points to the start of an active record on the stack.

54 3.3.3 Process Control Structures(6/10)
Process Control Information Scheduling and State Information Process state: defines the readiness of the process to be scheduled for execution (e.g., running, ready, waiting, halted). Priority: One or more fields may be used to describe the scheduling priority of the process. In some systems, several values are required (e.g., default, current, highest-allowable) Scheduling-related information: This will depend on the scheduling algorithm used. (e.g., waiting time, running time. Event: Identity of event the process is awaiting before it can be resumed

55 3.3.3 Process Control Structures(7/10)
Process Control Information Data Structuring A process may be linked to other process in a queue, ring, or some other structure. For example: all processes in a waiting state for a particular priority level may be linked in a queue. A process may exhibit a parent-child (creator- created) relationship with another process. The process control block may contain pointers to other processes to support these structures.

56 3.3.3 Process Control Structures(8/10)
Process Control Information Interprocess Communication Flags(标志) Signals(信号) Messages(消息) Process Privileges Processes are granted privileges in terms of the memory that may be accessed and the types of instructions that may be executed. In addition, privileges may apply to the use of system utilities and services.

57 3.3.3 Process Control Structures(9/10)
Process Control Information Memory Management This section may include pointers to segment and/or page tables that describe the virtual memory assigned to this process. Resource Ownership and Utilization Resources controlled by the process may be indicated, such as opened files. A history of utilization of the processor or other resources may also be included This information may be needed by the scheduler.

58 3.3.3 Process Control Structures(10/10)
PCB of Linux 结构体:task_struct Digging Deeper /usr/src/…/include/linux/sched.h Reference:

59 Chap3 Process Description and Control
3.1 What is a Process 3.2 Process States 3.3 Process Description 3.4 Process Control 3.5 Execution of the Operating System


Download ppt "Chapter 3 Process Description and Control"

Similar presentations


Ads by Google