You are on page 1of 10

03 Process Concept

Operating
Systems

Objectives

Process Concept

Process Life Cycle

Process Control Block

Operating
Systems

Processes

A process is a program in execution

Programs exist as files

A program that is run becomes a process

Operating
Systems

Processes

More than just running code

Pointer to currently executing instruction

Memory address for program code and data

List of open files or other resources

Etc.

Operating
Systems

Multiple Processes

OS runs multiple processes at the same time


OS must keep track not only process information but
information about interaction between processes

Operating
Systems

Multiple Processes

Need to keep track of the following

Interprocess Communication

CPU Scheduling

Resource allocation

Process synchronization

Deadlock issue

The next slides show some questions with regards to each.

Operating
Systems

Interprocess Communication

Should process be able to influence other processes during


execution?
What should a process do to send or receive information
from other processes?

Operating
Systems

CPU Scheduling

A single processor can run only one process at a time

Which process to allocate to the CPU?

How long the CPU is given to the process before another


process must execute?

Operating
Systems

Resource Allocation

Processes compete over limited system resources

Memory

Hard disk space

CPU time

Peripherals such as monitors, printers, etc

Which resource to allocate to which process?

What it two processes access the printer at the same time?

Operating
Systems

Process Synchronization

Processes running concurrently may need to have an order


of execution
Consider the following scenarios

Process 1 must write to a file before Process 2

Only a single process must be allowed to write to a file at any given


time

Operating
Systems

10

Deadlocks

What if two or more processes are waiting for each other to


finish before they proceed with execution.
For example

Process 1, writing to a file, is waiting for Process 2 to finish with the


printer to finish running.

Process 2, holding the printer, is waiting for Process 1 to finish with


the file before it can finish running

Process 1 and Process 2 are waiting for each other to finish


and thus none of them do
Does the OS prevent this, or allow this to happen but
recover, or just ignore the problem?
Operating
Systems

11

Process Life Cycle

Process undergoes the following life cycle

Operating
Systems

12

Process Life Cycle

New newly created process is loaded into memory


Ready: The process is ready for execution. It waits in the
ready queue until it is given CPU time.

Running: The processes is running on the CPU, currently


executing program instructions
Waiting: The process is waiting for I/O.

Terminated: The process has finished execution and is


waiting for the OS to deallocate it from memory and to clear
any used resources.

Operating
Systems

13

Process Life Cycle

Process that are ready to execute are placed in the ready


queue
A processor can execute only a single process

Scheduler chooses between processes in the ready queue


for execution

Only one process is in the running state

Movement from Ready to Running

Scheduler may make the running process go to the ready


queue

For instance, a higher priority process must be executed

Operating
Systems

14

Process Life Cycle

A process undergoes a CPU burst I/O burst cycle

CPU burst process is executing

I/O burst process is waiting for I/O

Process in I/O burst is moved to wait state

Allow other process to run on CPU

Process done with I/O is sent to the ready queue for next
CPU burst

Operating
Systems

15

Process Control Block

Data structure by OS to keep track of a process

PCB usually keeps track of:

Process identifier

Register values

Program counter currently executing code in process

Memory Address space

Process accounting information this includes process priority, the


amount of time used by the process in the CPU, or any additional
information needed by the OS
I/O status information list of files or devices being used by the process.

Operating
Systems

16

Context Switch

Context switch occurs when a process is moved from the


running state to the waiting or ready state.
To load process again later, CPU needs information stored
in the PCB.
A process entering the CPU gets its PCB information
loaded, register values set, program counter pointer loaded,
etc.
A process exiting the CPU gets its information stored in the
PCB so that the CPU will know where it left off when that
process returns to the running state.

Operating
Systems

17

Context Switch

Operating
Systems

18

Exercise
Search a complete java program. Identify each line if a CPU
burst or I/O burst cycle.

Operating
Systems

19

10

You might also like