UNIT-II
PROCESS MANAGEMENT
2. Process Management: A process can be thought of as a program in execution. A process will
need certain resources—such as CPU time, memory, files, and I/O devices—to accomplish its task.
These resources are allocated to the process either when it is created or while it is executing. A
process is the unit of work in most systems. Systems consist of a collection of processes: operating-
system processes execute system code, and user processes execute user code. All these processes may
execute concurrently.Although traditionally a process contained only a single thread of control as it
ran, most modern operating systems now support processes that have multiple threads.
The operating system is responsible for several important aspects of process and
thread management: the creation and deletion of both user and system processes; the scheduling of
processes; and the provision of mechanisms for synchronization, communication, and deadlock
handling for processes.
2.1 Process Concept:-
Process: A process is a program in execution.
For example, when we write a program in C or C++ and compile it, the compiler creates binary code.
The original code and binary code are both programs. When we actually run the binary code, it
becomes a process.
A process is more than the program code, which is sometimes known as the text section.
It also includes the current activity, as represented by the value of the program counter and the
contents of the processor’s registers. A process generally also includes the process stack, which
contains temporary data (such as function parameters, return addresses, and local variables), and a
data section, which contains global variables.A process may also include a heap, which is memory
that is dynamically allocated during process run time.
The structure of a process in memory is shown in Figure 3.1
1
,A program by itself is not a process. A program is a passive entity, such as a file containing a list of
instructions stored on disk (often called an executable file). In contrast, a process is an active entity,
with a program counter specifying the next instruction to execute and a set of associated resources.
Process Vs Program
Process Program
The process is basically an A Program is basically a collection of
instance of the computer program instructions that mainly performs a specific
that is being executed. task when executed by the computer.
A process has a shorter lifetime. A Program has a longer lifetime.
A Program is stored by hard-disk and does not
A Process requires resources such
require any resources.
as memory, CPU, Input-Output
2
, Process Program
devices.
A process has a dynamic instance
A Program has static code and static data.
of code and data
Basically, a process is On the other hand, the program is
the running instance of the code. the executable code.
2.2 Process State:
A process is a program in execution and it is more than a program code called as text section and this
concept works under all the operating system because all the task perform by the operating system
needs a process to perform the task.
The process executes when it changes the state. The state of a process is defined by the current activity
of the process.
A process may be in one of the following states −
● New − The process is being created.
● Running − In this state the instructions are being executed.
● Waiting − The process is in waiting state until an event occurs like I/O operation completion or
receiving a signal.
● Ready − The process is waiting to be assigned to a processor.
● Terminated − the process has finished execution.
It is important to know that only one process can be running on any processor at any instant. Many
3
, processes may be ready and waiting.
Now let us see the state diagram of these process states −
FIG:Diagram of process state.
Explanation:
Step 1 − Whenever a new process is created, it is admitted into ready state.
Step 2 − If no other process is present at running state, it is dispatched to running based on scheduler
dispatcher.
Step 3 − If any higher priority process is ready, the uncompleted process will be sent to the waiting
state from the running state.
Step 4 − Whenever I/O or event is completed the process will send back to ready state based on the
interrupt signal given by the running state.
Step 5 − Whenever the execution of a process is completed in running state, it will exit to terminate
state, which is the completion of process
4
PROCESS MANAGEMENT
2. Process Management: A process can be thought of as a program in execution. A process will
need certain resources—such as CPU time, memory, files, and I/O devices—to accomplish its task.
These resources are allocated to the process either when it is created or while it is executing. A
process is the unit of work in most systems. Systems consist of a collection of processes: operating-
system processes execute system code, and user processes execute user code. All these processes may
execute concurrently.Although traditionally a process contained only a single thread of control as it
ran, most modern operating systems now support processes that have multiple threads.
The operating system is responsible for several important aspects of process and
thread management: the creation and deletion of both user and system processes; the scheduling of
processes; and the provision of mechanisms for synchronization, communication, and deadlock
handling for processes.
2.1 Process Concept:-
Process: A process is a program in execution.
For example, when we write a program in C or C++ and compile it, the compiler creates binary code.
The original code and binary code are both programs. When we actually run the binary code, it
becomes a process.
A process is more than the program code, which is sometimes known as the text section.
It also includes the current activity, as represented by the value of the program counter and the
contents of the processor’s registers. A process generally also includes the process stack, which
contains temporary data (such as function parameters, return addresses, and local variables), and a
data section, which contains global variables.A process may also include a heap, which is memory
that is dynamically allocated during process run time.
The structure of a process in memory is shown in Figure 3.1
1
,A program by itself is not a process. A program is a passive entity, such as a file containing a list of
instructions stored on disk (often called an executable file). In contrast, a process is an active entity,
with a program counter specifying the next instruction to execute and a set of associated resources.
Process Vs Program
Process Program
The process is basically an A Program is basically a collection of
instance of the computer program instructions that mainly performs a specific
that is being executed. task when executed by the computer.
A process has a shorter lifetime. A Program has a longer lifetime.
A Program is stored by hard-disk and does not
A Process requires resources such
require any resources.
as memory, CPU, Input-Output
2
, Process Program
devices.
A process has a dynamic instance
A Program has static code and static data.
of code and data
Basically, a process is On the other hand, the program is
the running instance of the code. the executable code.
2.2 Process State:
A process is a program in execution and it is more than a program code called as text section and this
concept works under all the operating system because all the task perform by the operating system
needs a process to perform the task.
The process executes when it changes the state. The state of a process is defined by the current activity
of the process.
A process may be in one of the following states −
● New − The process is being created.
● Running − In this state the instructions are being executed.
● Waiting − The process is in waiting state until an event occurs like I/O operation completion or
receiving a signal.
● Ready − The process is waiting to be assigned to a processor.
● Terminated − the process has finished execution.
It is important to know that only one process can be running on any processor at any instant. Many
3
, processes may be ready and waiting.
Now let us see the state diagram of these process states −
FIG:Diagram of process state.
Explanation:
Step 1 − Whenever a new process is created, it is admitted into ready state.
Step 2 − If no other process is present at running state, it is dispatched to running based on scheduler
dispatcher.
Step 3 − If any higher priority process is ready, the uncompleted process will be sent to the waiting
state from the running state.
Step 4 − Whenever I/O or event is completed the process will send back to ready state based on the
interrupt signal given by the running state.
Step 5 − Whenever the execution of a process is completed in running state, it will exit to terminate
state, which is the completion of process
4