Process: 8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

PROCESS

Most requirements of operating systems must meet through the processes:

• The OS must interleave the execution of multiple processes to maximize processor


utilization while providing reasonable response time

• The OS must allocate resources to processes in conformance with a specific policy while
at the same time avoiding deadlock.

• The OS may be required to support inter-process communication and user creation of


processes, both of which may aid in the structuring of applications.

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 1


A process definition…………

A process consists of a program code and associated data plus control block

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 2


Simplified process control block

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 3


A process is characterized by the following elements:

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 4


Memory layout of 3 processes ( for simplification no use of virtual memory)

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 5


• Process is characterized by sequence of instructions that are executed for that process.

• Such listing is referred to as trace of that process.

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 6


8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 7
Process states for the trace given in fig,

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 8


8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 9
Process creation

When a new process is CREATED the OS builds the data structures that are used to manage
the process and allocates address space in main memory to the process.

• In a batch environment, a process is created in response to the submission of a job.

• In interactive environment, a process is created when a new user attempts to log on.

• An OS may also create a process on behalf of an application.

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 10


Reasons for process creation

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 11


Reasons for process termination

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 12


2-state process model

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 13


Limitations of 2 state model :
Some processes in the Not running state are ready to execute, while others are blocked, waiting
for an I/O operation to complete.

This using a single queue, the dispatcher could not just select the process at the oldest end of the
queue.

Solutions:

Rather, dispatcher would have to scan the list blocking for the process that has been in the queue
the longest.

This could be possible by splitting not running state in to TWO states: READY and BLOCKED.

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 14


Process states
• New: Process has been created but hasn’t yet got admission in ready queue.
• Ready: Submitted for execution, all resources are assigned except CPU.
• Running: Currently running on CPU
• Blocked: Cannot execute until specific event occurs
• Exit: Normal or abnormal termination of process

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 15


A 5 state process model

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 16


8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 17
When a process is removed from execution, it is either terminated or placed in the Ready or
Blocked queue, depending on the circumstances.

When the event occurs, all the processes in the Blocked queue, waiting for that event are
moved to the Ready queue.
8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 18
8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 19
The OS must scan the entire blocked queue, when an event occurs, searching for those
processes waiting on that event.

In a large OS, there will be more number of events, and hence it would be more efficient to
have number of queues, one for each event.

Flaws:

Processor is much faster than the I/O, and it is common for all of the processes in memory to
be waiting for an I/O.
By memory (main) expansion, cost will be increased.

Solution:

Swapping, which involves moving part or all of the process from main memory to disk.
( NOTE:- Time consuming but disk I/O is the fastest I/O on the system).
8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 20
When all of the processes in main memory are in the Blocked state, the operating system
can suspend one process by putting it in the suspended state by transferring it to disk.

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 21


8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 22
8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 23
Reasons for process suspension

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 24


Suspended process has the following characteristics:

 The process is not immediately available for the execution

 The process may or may not be waiting on an event. If it is , this blocked condition is
independent of suspend condition, and occurrence of the blocking event does not enable the
process to be executed.

 The process was placed in a suspended state by an agent; either itself, a parent process, or
the operating system, for the purpose of preventing its execution

 The process may not be removed from this state until the agent explicitly orders the
removal.

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 25


Process Control Block

A table containing all information about the process:


• The Unique Process Id
• The process state
• Scheduling information with respect to it.
• Register used and the contents
• Pointers to the memory it uses
• Program counter value
• Priority of the task

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 26


Process in memory

Multiple Processes Single Process Layout

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 27


Memory Layout of Program
Stack for function main()
vars : x,y and sum
int tax = 0;
Stack for function add()
int add (int a , int b) Vars : a, b and total
{
int total;
total = a + b + tax;
return total;
} HEAP
int main()
{ Var : tax
int x, y, sum;
x = 5; Code section for function main
y = 6; and add
sum = add (x, y);
}
8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 28
Reference :

William Stallings , Operating systems, PHI

8/26/2022 Dr. Kanthi.M, Professor, ECE Dept., MIT 29

You might also like