3 Process Management
3 Process Management
Process Management
Introduction:
A running instance of a program is called as a process. A process is a smallest unit
of work that is scheduled by the operating system.
A process needs resources, such as CPU time, memory, files and I/0 devices, to
accomplish its task. These resources are allocated either when the program is
created or when it is executing.
The process concept helps to explain, understand and organize execution of
programs in an operating system.
A user uses processes to achieve execution of programs in a sequential or concurrent
manner as desired.
An OS uses processes to organize execution of programs. Use of the process
concept enables an OS to execute both sequential and concurrent programs equally
easily.
Process management is the fundamental task of any modern operating system. The
OS must allocate resources to processes, enable processes to share and exchange
information, protect the resources of each process from other processes and enable
synchronization among processes.
To meet these requirements, the Os must maintain a data structure for each process,
which describes the state and resource ownership of that process, and which enables
the OS to exert control over each process.
PROCESS:
A process is defined as, "an entity which represents the
basic unit of work to be implemented in the system".
A process is defined as, "a program under execution,
which competes for the CPU time and other resources.“
A process is a program in execution. Process is also called
as job, task and unit of work.
A process is an instance of an executing program,
including the current values of the program counter,
registers and variables.
Logically each process has its separate virtual CPU. In
actual, the real CPU switches from one process to another.
A process is an activity and it has a program, input, output
and a state.
Each process has following sections:
1.A Text section that contains the program code.
2. A Data section that contains global and static variables,
3. The heap is used for dynamic memory allocation, and is
managed via calls to new, delete, malloc, free, etc.
4. The stack is used for local variables. A process stack
which contains the temporary data (such as subroutine
parameters, return addresses, and temporary variables).
Space on the stack is reserved for local variables when
they are declared(at function entrance or elsewhere,
depending on the language), and the space is freed up
when the variables go out of scope.
5. A program counter that contains the contents of
processor's registers.
Process model:
Process states:
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(the lock for which is already acquired) 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.
3. Process State: This information is about the current state of the process.
The state may be new ready, running, and waiting, halted, and so on.
4. Program Counter: The counter indicates the address of the next
instruction to be executed for this process.
5.CPU Registers: The registers vary in number and type,
depending on the computer architecture. They include
accumulators, index registers, stack pointers, and general-purpose
registers, plus any condition-code information. Along with the
program counter, this state information must be saved when an
interrupt occurs, to allow the process to be continued correctly
afterward.
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.
Syntax: ps [option]