Top Banner
1 1 Process Description and Control Chapter 3 Sequence 5 CS240 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
14

Process Description and Control

Jan 27, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Process Description and Control

1

1

Process Description and Control

Chapter 3

Sequence 5 CS240 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

Page 2: Process Description and Control

2

Sequence 5 CS240 3

Manage Execution of Applications

•  Resources made available to multiple applications

•  Processor is switched among multiple application

•  The processor and I/O devices can be used efficiently

Sequence 5 CS240 4

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 instructions

Page 3: Process Description and Control

3

Sequence 5 CS240 5

Process Elements •  Identifier •  State •  Priority •  Program counter •  Memory pointers •  Context data •  I/O status information •  Accounting information

Sequence 5 CS240 6

Process Control Block

•  Contains the process elements •  Created and manage by the operating

system •  Allows support for multiple processes

Page 4: Process Description and Control

4

Sequence 5 CS240 7

Process Control Block Identifier

Figure 3.1 Simplified Process Control Block

State

Priority

Program counter

Memory pointers

Context data

I/O statusinformation

Accountinginformation

Sequence 5 CS240 8

Trace of Process

•  Sequence of instruction that execute for a process

•  Dispatcher switches the processor from one process to another

Page 5: Process Description and Control

5

Sequence 5 CS240 9

Example Execution Main MemoryAddress

Dispatcher

Process A

Process B

Process C

Program Counter0

100

5000

8000

8000

12000

Figure 3.2 Snapshot of Example Execution (Figure 3.4)at Instruction Cycle 13

Sequence 5 CS240 10

Trace of Processes

Process B is waiting for I/O

Page 6: Process Description and Control

6

Sequence 5 CS240 11

Sequence 5 CS240 12

Two-State Process Model •  Process may be in one of two states

–  Running –  Not-running

Page 7: Process Description and Control

7

Sequence 5 CS240 13

Not-Running Process in a Queue

Sequence 5 CS240 14

Process Creation

Page 8: Process Description and Control

8

Sequence 5 CS240 15

Process Termination

Sequence 5 CS240 16

Process Termination

Page 9: Process Description and Control

9

Sequence 5 CS240 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

Sequence 5 CS240 18

A Five-State Model

•  Running •  Ready •  Blocked •  New •  Exit

Page 10: Process Description and Control

10

Sequence 5 CS240 19

Five-State Process Model

Sequence 5 CS240 20

Let’s look at the execution again. What are the state transitions of the processes?

Page 11: Process Description and Control

11

Sequence 5 CS240 21

Process States

Sequence 5 CS240 22

Using Two Queues

Is the Blocked Queue a FIFO queue? What is the problem with the Blocked Queue?

Page 12: Process Description and Control

12

Sequence 5 CS240 23

Multiple Blocked Queues

Event 1 Wait

Event 2 Wait

Event n Wait

DispatchReleaseReady Queue

AdmitProcessor

Timeout

Event 1 QueueEvent 1Occurs

Event 2Occurs

Event nOccurs

Event 2 Queue

Event n Queue

(b) Multiple blocked queues

Sequence 5 CS240 24

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 •  Two new states

– Blocked/Suspend – Ready/Suspend

Page 13: Process Description and Control

13

Sequence 5 CS240 25

One Suspend State

Sequence 5 CS240 26

Two Suspend States

Page 14: Process Description and Control

14

Sequence 5 CS240 27

Reasons for Process Suspension