Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Process Description and Control Chapter 3. 2 Requirements of an Operating System Interleave the execution of multiple processes to maximize processor.

Similar presentations


Presentation on theme: "1 Process Description and Control Chapter 3. 2 Requirements of an Operating System Interleave the execution of multiple processes to maximize processor."— Presentation transcript:

1 1 Process Description and Control Chapter 3

2 2 Requirements of an Operating System Interleave the execution of multiple processes to maximize processor utilization while providing reasonable response time Allocate resources to processes Support interprocess communication and user creation of processes

3 3 What is a Process? 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, and an associated set of system resources

4 4 Process Elements A process is an entity that consists of a number of elements. Two essential elements are program code( 程序代码 ) and a set of data( 与代码相关的数 据集 ). When the program is executing, it need include the following elements: Identifier (标识符) State (进程状态) Priority (优先级) Program counter (程序计数器) Memory pointers (内存指针) Context data (上下文数据) I/O status information ( I/O 状态信息) Accounting information (统计信息)

5 5 Process Control Block ( PCB , 进程控制块) Contains the process elements Created and manage by the operating system Allows OS to support for multiple processes

6 6 Process Control Block So, a process consists of program code and associated data plus a PCB

7 7 Trace of Process Sequence of instruction that execute for a process Dispatcher switches the processor from one process to another

8 8 Example Execution

9 9 Trace of Processes

10 10

11 11 Two-State Process Model Process may be in one of two states Running Not-running

12 12 Not-Running Process in a Queue When the operating system creates a new process, it enters the process into the system in the Not-running state.

13 13 Process Creation The operating system builds the data structures that are used to manage the process and allocates address space in main memory to the process.

14 14 Process Creation

15 15 Process Termination

16 16

17 17 Processes Not-running Ready to execute Blocked waiting for I/O Dispatcher cannot just select the process that has been in the queue the longest because it may be blocked

18 18 A Five-State Model Running (运行) Ready (就绪) Blocked (阻塞) New (新建) : PCB has been created, but not loaded into main memory Exit (退出)

19 19 Five-State Process Model

20 20 Process States

21 21 Using Two Queues

22 22 Multiple Blocked Queues

23 23 Suspended( 挂起 ) Processes Processor is faster than I/O so all processes could be waiting for I/O Swap these processes to disk to free up more memory Blocked state becomes suspend state when swapped to disk

24 24 One Suspend State

25 25 Two Suspend States Blocked/Suspend (阻塞 / 挂起) Ready/Suspend (就绪 / 挂起)

26 26 Reasons for Process Suspension

27 27 Processes and Resources What information does the OS need to control processes and manage resources for them?

28 28 Operating System Control Structures Information about the current status of each process and resource Tables are constructed for each entity the operating system manages Four different types of tables: memory, I/O, file, process

29 29

30 30 Memory Tables( 存储表 ) keep track of both main and secondary memory. 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

31 31 I/O Tables(I/O 表 ) Manage the I/O devices and channels of the computer system. 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

32 32 File Tables( 文件表 ) Existence of files Location on secondary memory Current Status Attributes Sometimes this information is maintained by a file management system

33 33 Process Table( 进程表 ) Where process is located? What its attributes are managed? Process include: Program Data Stack Attributes in the process control block

34 34 Process Image( 进程映象 )

35 35 Process Control Block ( PCB , 进程控制块) Contains the process elements Created and manage by the operating system Allows support for multiple processes

36 36 Process Control Block Three general categories: Process identification( 进程标识 ) Processor State Information( 进程状 态信息 ) Process Control Information( 进程 控制信息 )

37 37 Process identification 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 (parent process) User identifier

38 38 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. Control and Status Registers These are a variety of processor registers that are employed to control the operation of the processor. Stack Pointers

39 39 Process Control Information Scheduling and State Information Process state( 进程状态 ) Priority( 优先级 ) Scheduling-related information( 相关调 度信息 ) Event( 进程等待的事件 ) Data Structuring Interprocess Communication

40 40 Process Control Information Process Privileges (进程特权) Allow to access memory and to execute some instructions 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

41 41 Process Control Block

42 42 Process Control Modes of Execution User mode Less-privileged mode User programs typically execute in this mode System mode, control mode, or kernel mode More-privileged mode Kernel of the operating system

43 43 Process Creation Assign a unique process identifier Allocate space for the process Initialize process control block Set up appropriate linkages Ex: add new process to linked list used for scheduling queue Create of expand other data structures Ex: maintain an accounting file

44 44 When to Switch a Process Clock interrupt process has executed for the maximum allowable time slice I/O interrupt Memory fault memory address is in virtual memory so it must be brought into main memory

45 45 When to Switch a Process Trap error or exception occurred may cause process to be moved to Exit state Supervisor call such as file open

46 46 Steps of Process Switch Save context of processor including program counter and other registers Update the process control block of the process that is currently in the Running state Move process control block to appropriate queue – ready; blocked; ready/suspend Select another process for execution

47 47 Update the process control block of the process selected: Running Update memory-management data structures Restore context of the selected process: load in the previous values of the PC and other register Steps of Process Switch

48 48 Execution of the Operating System Is the operating system a process? Non-process Kernel Execute kernel outside of any process Operating system code is executed as a separate entity that operates in privileged mode Execution Within User Processes Operating system software within context of a user process Process executes in privileged mode when executing operating system code

49 49 Process-Based Operating System Implement operating system as a collection of system processes Useful in multi-processor or multi- computer environment Execution of the Operating System

50 50


Download ppt "1 Process Description and Control Chapter 3. 2 Requirements of an Operating System Interleave the execution of multiple processes to maximize processor."

Similar presentations


Ads by Google