Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 23

Operating Systems &

Computer Architecture
CT049-3-1-OS&CA
Ver: VD1

Process Control Management


Learning Outcomes

At the end of this section, YOU should be able to:

• Define Processes and Threads


• Draw and explain; the process state diagram, the process scheduling diagram and PCB

CT049-3-1-OS&CA Process Control 2 2 of 23


Topics we will cover
• Process and Thread Concepts
• Process States
• Process Scheduling

CT049-3-1-OS&CA Process Control 3 3 of 23


Process

• What is a process?
– it is a program in execution which progresses
in a sequential manner.
– it is a unit of work with a unique process
identification.
– requires resources like memory, CPU time
and files to complete its task.

CT049-3-1-OS&CA Process Control 4 of 23


Process

• What is a process?
– resources are allocated when a process is
created or while in execution
– the operating system creates and deletes
user and system processes
– a process is active while a program is
passive
– the operating system keeps track of
processes using a process table

CT049-3-1-OS&CA Process Control 5 of 23


Process State Diagram

new
new terminated
terminated
admitted exit
Interrupt / time out

ready
ready running
running

scheduler dispatcher
I/O or event I/O or event wait
completion
blocked
blocked

CT049-3-1-OS&CA Process Control 6 of 23


Process States

• As a program executes, it changes states


• New
– A process has just been created
– Reasons for process creation
• new batch job
• interactive logon
– Upon creation, a New process becomes Ready
• Ready
– the process is waiting to be assigned to a processor

CT049-3-1-OS&CA Process Control 7 of 23


Process States (cont.)

• Ready - Running
– instructions are being executed
– a process is using the CPU
– the number of running processes will depend on the number of
processors the computer has
• A running process can possibly become Blocked, Ready
or Terminated
• A Running process becomes Blocked when:-
– the process itself cannot execute because it is waiting for an I/O
operation to complete
– waiting for some external event to happen

CT049-3-1-OS&CA Process Control 8 of 23


Process States (cont.)

• From the Blocked state a process moves to the


Ready state when the event which the process
was waiting for occurs.
• A Running process moves to the Ready state
when:-
– a process has reached its maximum allowable time
for uninterrupted execution.
– a process needs a resource that is not immediately
available.
– a process needs an I/O operation before continuation.

CT049-3-1-OS&CA Process Control 9 of 23


Process States (cont.)

• From the Running state a process moves into the


Terminated state when:-
– the process has completed
– the process has been aborted
• Reasons for process termination:-
– normal completion
– invalid instruction
– memory unavailable
• Upon termination, control is then returned to the
operating system.

CT049-3-1-OS&CA Process Control 10 of 23


Quick Review Questions

1. For each of the following transitions


between process states, indicate whether
the transition is possible or not possible?
ready → running
ready → new
blocked → ready
2. On a system with n number of CPU’s
what is the minimum number of
processes that can be in the ready,
running and blocked state?
CT049-3-1-OS&CA Process Control 11 of 23
Process Control Block (PCB)

• Each process is represented in the


operating system as a process control
block.
• A Process Control Block (PCB):-
– keeps track of each process.
– contains information associated with a
specific process.
– serves as a repository of any information
that may vary from process to process.
CT049-3-1-OS&CA Process Control 12 of 23
Process Control Block Diagram
Pointer to parent process
Pointer area to child process
Process state
Program counter
Register save area
Memory limits
Priority information
Accounting information
Pointer to files and other
I/O resources

CT049-3-1-OS&CA Process Control 13 of 23


Process Control Block Diagram

• Process state – the process state; ready,


running, blocked, terminated.
• Program counter – indicates the location for the
next instruction.
• CPU scheduling information – process
priority, pointers to scheduling queues.
• Accounting information – statistics on CPU
time, job and process numbers.
• I/O status – list of I/O devices which are
allocated to processes.

CT049-3-1-OS&CA Process Control 14 of 23


Process Scheduling

• As processes enter the system, they are put on the job


queue.
• A new process is put on the ready queue.
• The process waits until it is selected for execution (or
dispatched) and given CPU resources.
• Once the CPU is allocated and the process is running:-
– the process could issue an I/O request and be placed on a
device queue.
– the process could create a new sub-process.
– the process could be forcibly removed.

CT049-3-1-OS&CA Process Control 15 of 23


Process Scheduling Diagram

readyqueue
ready queue CPU
CPU

I/O
I/O I/OQueue
I/O Queue I/ORequest
I/O Request

timeslice
time slice
expired
expired

child
child childexecute
child execute forkaachild
fork child
terminates
terminates

interrupt
interrupt waitfor
wait foran
an
occurs
occurs interrupt
interrupt

CT049-3-1-OS&CA Process Control 16 of 23


Concurrent Processes

• Concurrent processes can be


independent or cooperating processes.
• Independent processes are processes
that do not need to interact with other
processes.
• Cooperating processes are processes that
work with each other, can affect or be
affected by another process.

CT049-3-1-OS&CA Process Control 17 of 23


Concurrent Processes (cont.)

• Why should an operating system allow for


cooperating processes?
– information sharing and to allow access to
resources using the PCB.
– increase computation speed.

CT049-3-1-OS&CA Process Control 18 of 23


Thread

• A mini lightweight process that can


execute independently of other parts of the
process
• Two types of threads:-
– user processes
– system processes
• Creation of a new process (child) from the
older one (parent) is called spawning or
forking.
CT049-3-1-OS&CA Process Control 19 of 23
Quick Review Questions

1. What is a process control block?


2. Draw and briefly explain the process
scheduling diagram.

CT049-3-1-OS&CA Process Control 20 of 23


Follow Up Assignment

1. What are the differences and similarities


between a process and a thread?
2. Draw and explain the process state
diagram.
3. What does a process table store?

CT049-3-1-OS&CA Process Control 21 of 23


Summary of Main Teaching
Points
• A process is a unit of work in execution
which requires resources.
• The state of a processes changes as it
executes.
• A process control block represents a
process in the operating system.
• Processes can execute concurrently or
independently from each other.
• A thread is a basic unit of CPU utilisation.
CT049-3-1-OS&CA Process Control 22 of 23
END

Q&A
CT049-3-1-OS&CA Process Control 23 of 23

You might also like