Process and Process Operation

You might also like

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

Process and Process Operation

A process is, a program in execution. It is operation of operating system.


For example when user wishes print a file, the operating system on behalf of
the user program, will create a process that will control the printing task. At
the time booting also several processes that runs in the background known as
daemon processes. There are various operation performed on process.

Process Operations are as follows;


1. Process creation
2. Process Dispatching
3. Process Blocking/wakeup
4. Process termination

 Process Creation:
 process can create several new processes through creating a process
system calls during the process execution. Creating a process, we call it
the parent process and the new process is a child process.
 Every new process creates another process forming a tree-like structure.
It can be identified with a unique process identifier that usually
represents it as pid which is typically an integer number. Every process
needs some resources like CPU time, memory, file, I/O devices to
accomplish.
 Whenever a process creates a sub process, and may be each sub process
is able to obtain its resources directly from the operating system or from
the resources of the parent process. The parent process needs to partition
its resources among all its children or it may be able to share some
resources to several children.
 A process is going to obtain its resources whenever it is created.
 Let us consider a tree of process as follows −
Whenever a process creates a new process, there are two possibilities in terms
of execution, which are as follows −
 The parent continues to execute concurrently with its children.
 The parent waits till some or all its children have terminated.
There are two more possibilities in terms of address space of the new process,
which are as follows −
 The child process is a duplicate of the parent process.(it has same
data and program as a parent)
 The child process has a new program loaded into it.

In UNIX , there is one parent process called init(), other system processes are
created from this process.
The fork() command a new child process is created having same environment,
resources and so on as the parent process, that is, the new process has the copy
of the address space of parent process. Both parent and child process continue
to get execution. However the copy of address space in child process does not
mean that there is sharing of the address space. Both address space are
different and non sharable.
If child process wishes to have separate code than another system call
execlp() needs to be executed. This command loads new program in memory
replacing the old parents program.
Windows OS does not have provision of duplicating the address space
while creating a child process.
Process dispatching: The event or activity in which the state of the process is
changed from ready to running. It means the operating system puts the process
from ready state into the running state. Dispatching is done by operating
system when the resources are free or the process has higher priority than the
ongoing process.
3. Blocking: When a process invokes an input-output system call that blocks
the process and operating system put in block mode. Block mode is basically a
mode where process waits for input-output. Hence on the demand of process
itself, operating system blocks the process and dispatches another process to
the processor. Hence, in process blocking operation, the operating system puts
the process in ‘waiting’ state.

4. Preemption: When a timeout occurs that means the process hadn’t been
terminated in the allotted time interval and next process is ready to execute,
then the operating system preempts the process. This operation is only valid
where CPU scheduling supports preemption. Basically this happens in priority
scheduling where on the incoming of high priority process,and the ongoing
process is preempted.

5. Termination: Process termination is the activity of ending the process. In


other words, process termination is the relaxation of computer resources taken
by the process for the execution. Like creation, in termination also there may
be several events that may lead to the process termination. Some of them are:
 Process completes its execution fully and it indicates to the OS that it
has finished.
 Operating system itself terminates the process due to service errors.
 There may be problem in hardware that terminates the process.
Process Control Block (PCB)

 While creating a process the operating system performs several


operations.
 To identify the processes, it assigns a process identification number
(PID) to each process.
 As the operating system supports multi-programming, it needs to keep
track of all the processes. For this task, the process control block
(PCB) is used to track the process’s execution status.
 Each block of memory contains information about the process state,
program counter, stack pointer, status of opened files, scheduling
algorithms, etc.
 All these information is required and must be saved when the process
is switched from one state to another. When the process makes a
transition from one state to another, the operating system must update
information in the process’s PCB.

 Pointer – It is a stack pointer which is required to be saved when


the process is switched from one state to another to retain the
current position of the process.
 Process state – It stores the respective state of the process.
 Process number – Every process is assigned with a unique id
known as process ID or PID which stores the process identifier.
 Program counter – It stores the counter which contains the
address of the next instruction that is to be executed for the
process.
 Register – These are the CPU registers which includes:
accumulator, base, registers and general purpose registers.
 Memory limits – This field contains the information about memory
management system used by operating system. This may include
the page tables, segment tables etc.
 Open files list – This information includes the list of files opened
for a process.

Process state transition/Life Cycle of Process

 New (Create) – In this step, the process is about to be created but not
yet created, it is the program which is present in secondary memory that will
be picked up by OS to create the process.
 Ready – New -> Ready to run. After the creation of a process, the
process enters the ready state i.e. the process is loaded into the main memory.
The process here is ready to run and is waiting to get the CPU time for its
execution. Processes that are ready for execution by the CPU are maintained in
a queue for ready processes.
 Run – The process is chosen by CPU for execution and the instructions
within the process are executed by any one of the available CPU cores.
 Blocked or wait – Whenever the process requests access to I/O or needs
input from the user or needs access to a critical region it enters the blocked or
wait state. The process continues to wait in the main memory and does not
require CPU. Once the I/O operation is completed the process goes to the
ready state.
 Terminated or completed – Process is killed as well as PCB is deleted.
 Suspend ready – Process that was initially in the ready state but was
swapped out of main memory and placed onto external storage by scheduler is
said to be in suspend ready state. The process will transition back to ready
state whenever the process is again brought onto the main memory.
 Suspend wait or suspend blocked – Similar to suspend ready but uses
the process which was performing I/O operation and lack of main memory
caused them to move to secondary memory. When work is finished it may go
to suspend ready.
CPU and I/O Bound Processes: If the process is intensive in terms of CPU
operations then it is called CPU bound process. Similarly, If the process is
intensive in terms of I/O operations then it is called I/O bound process. Types
of schedulers:

You might also like