0% found this document useful (0 votes)
4 views

11_Operating Sytems-Process Control

Uploaded by

aashritpanta2004
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

11_Operating Sytems-Process Control

Uploaded by

aashritpanta2004
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Operating Systems &

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

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

Module Code & Module Title Slide Title SLIDE 2


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

Module Code & Module Title Slide Title SLIDE 3


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.

Module Code & Module Title Slide Title SLIDE 4


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

Module Code & Module Title Slide Title SLIDE 5


Process State Diagram

new
new terminated
terminated
admitted exi
t
Interrupt / time out

ready
ready running
running

scheduler
I/O or event dispatcher I/O or event wait
completion
blocked
blocked
Module Code & Module Title Slide Title SLIDE 6
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

Module Code & Module Title Slide Title SLIDE 7


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

Module Code & Module Title Slide Title SLIDE 8


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.

Module Code & Module Title Slide Title SLIDE 9


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.

Module Code & Module Title Slide Title SLIDE 10


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?

Module Code & Module Title Slide Title SLIDE 11


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.

Module Code & Module Title Slide Title SLIDE 12


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
otherSlide Title
Module Code & Module Title SLIDE 13
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.

Module Code & Module Title Slide Title SLIDE 14


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.

Module Code & Module Title Slide Title SLIDE 15


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

Module Code & Module Title Slide Title SLIDE 16


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.

Module Code & Module Title Slide Title SLIDE 17


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.

Module Code & Module Title Slide Title SLIDE 18


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.

Module Code & Module Title Slide Title SLIDE 19


Quick Review Questions

1. What is a process control block?


2. Draw and briefly explain the process scheduling diagram.

Module Code & Module Title Slide Title SLIDE 20


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?

Module Code & Module Title Slide Title SLIDE 21


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.

Module Code & Module Title Slide Title SLIDE 22


END

Q&A
Module Code & Module Title Slide Title SLIDE 23

You might also like