5 and 7 States of Process

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Assignment: Write 5 State and 7

State of Process and Its Difference


Advance Operating system

Prepared By: Moazzam Naeem 231852

4/9/2023
5 State of Process
A process is a program under execution that consists of a number of elements including, program
code and a set of data. To execute a program, a process has to be created for that program. Here the
process may or may not run but if it is in a condition of running then that has to be maintained by
the OS for appropriate progress of the process to be gained.

Need for Five-State Process Model

In five- state model the states have been split into two non-running states: ready and blocked, and
along with this, two more states are added for the purpose: New and Exit/Terminate. These two
states are used because, in the previous models, the main memory is capable to store all programs
but that is not true because the programs are now very large, and loading those processes in the
main memory is very tough/ or even not possible and also if there’s a requirement for using the
previous resources that are released by the process, then that is not possible here.

The five states that are being used in this process model are:

Running: It means a process that is currently being executed. Assuming that there is only a single
processor in the below execution process, so there will be at most one processor at a time that can
be running in the state.

Ready: It means a process that is prepared to execute when given the opportunity by the OS.

Blocked/Waiting: It means that a process cannot continue executing until some event occurs like for
example, the completion of an input-output operation.

New: It means a new process that has been created but has not yet been admitted by the OS for its
execution. A new process is not loaded into the main memory, but its process control block (PCB)
has been created.

Exit/Terminate: A process or job that has been released by the OS, either because it is completed or
is aborted for some issue.

Execution of Process in Two-state Model

This model consists of five states i.e, running, ready, blocked, new, and exit. The model works when
any new job/process occurs in the queue, it is first admitted in the queue after that it goes in the
ready state. Now in the Ready state, the process goes in the running state. In the running state, a
process has two conditions i.e., either the process goes to the event wait or the process gets a time-
out.
If the process has timed out, then the process again goes to the ready state as the process has not
completed its execution. If a process has an event wait condition then the process goes to the
blocked state and after that to the ready state. If both conditions are true, then the process goes to
running state after dispatching after which the process gets released and at last it is terminated.

Possible State Transitions

There can be various events that lead to a state transition for a process. The possible state
transitions are given below:

Null -> New: A new process is created for the execution of a process.

New -> Ready: The system will move the process from new to ready state and now it is ready for
execution. Here a system may set a limit so that multiple processes can’t occur otherwise there may
be a performance issue.

Ready -> Running: The OS now selects a process for a run and the system chooses only one process
in a ready state for execution.

Running -> Exit: The system terminates a process if the process indicates that is now completed or if
it has been aborted.

Running -> Ready: The reason for which this transition occurs is that when the running process has
reached its maximum running time for uninterrupted execution. An example of this can be a process
running in the background that performs some maintenance or other functions periodically.

Running -> Blocked: A process is put in the blocked state if it requests for something it is waiting.
Like, a process may request some resources that might not be available at the time or it may be
waiting for an I/O operation or waiting for some other process to finish before the process can
continue.
Blocked -> Ready: A process moves from blocked state to the ready state when the event for which
it has been waiting.

Ready -> Exit: This transition can exist only in some cases because, in some systems, a parent may
terminate a child’s process at any time.

Benefits:

The New and Exit state are very useful constructs for managing the process.

It is an efficient way of the previous two-state process model.

Drawbacks:

If a process gets terminated or exit from the OS, its data is not preserved by the OS.

There can be a performance issue as in a situation where each process goes to a blocked state the
CPU stays idle until at least one process leaves the waiting state.

7 Sates of Process
The process, from its creation to completion, passes through various states. The minimum number
of states is five.

The names of the states are not standardized although the process may be in one of the following
states during execution.
1. New

A program which is going to be picked up by the OS into the main memory is called a new process.

2. Ready

Whenever a process is created, it directly enters in the ready state, in which, it waits for the CPU to
be assigned. The OS picks the new processes from the secondary memory and put all of them in the
main memory.

The processes which are ready for the execution and reside in the main memory are called ready
state processes. There can be many processes present in the ready state.

3. Running

One of the processes from the ready state will be chosen by the OS depending upon the scheduling
algorithm. Hence, if we have only one CPU in our system, the number of running processes for a
particular time will always be one. If we have n processors in the system then we can have n
processes running simultaneously.

4. Block or wait

From the Running state, a process can make the transition to the block or wait state depending upon
the scheduling algorithm or the intrinsic behavior of the process.

When a process waits for a certain resource to be assigned or for the input from the user then the
OS move this process to the block or wait state and assigns the CPU to the other processes.

5. Completion or termination

When a process finishes its execution, it comes in the termination state. All the context of the
process (Process Control Block) will also be deleted the process will be terminated by the Operating
system.

6. Suspend ready

A process in the ready state, which is moved to secondary memory from the main memory due to
lack of the resources (mainly primary memory) is called in the suspend ready state.

If the main memory is full and a higher priority process comes for the execution then the OS have to
make the room for the process in the main memory by throwing the lower priority process out into
the secondary memory. The suspend ready processes remain in the secondary memory until the
main memory gets available.

7. Suspend wait

Instead of removing the process from the ready queue, it's better to remove the blocked process
which is waiting for some resources in the main memory. Since it is already waiting for some
resource to get available hence it is better if it waits in the secondary memory and make room for
the higher priority process. These processes complete their execution once the main memory gets
available and their wait is finished.

Operations on the Process

1. Creation

Once the process is created, it will be ready and come into the ready queue (main memory) and will
be ready for the execution.

2. Scheduling

Out of the many processes present in the ready queue, the Operating system chooses one process
and start executing it. Selecting the process which is to be executed next, is known as scheduling.

3. Execution

Once the process is scheduled for the execution, the processor starts executing it. Process may come
to the blocked or wait state during the execution then in that case the processor starts executing the
other processes.

4. Deletion/killing

Once the purpose of the process gets over then the OS will kill the process. The Context of the
process (PCB) will be deleted and the process gets terminated by the Operating system.

Difference between 5 states and 7 states of process


So the difference between these two models is of two states which are not present in five states but
present in seven states and they are Suspended ready and suspended wait.

You might also like