Process and Process Operation
Process and Process Operation
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.
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: