What is Process Management in Operating Systems

What is Process Management in Operating Systems

A process is a program at the time of execution. The process is more than the program code. It includes the program counter, the process stack, the content of the process register, etc. The purpose of the process stack is to store temporary data, such as subroutine parameters, return addresses, and temporary variables.

Process vs Program

There are many differences between process and program, some main points are:

  • A process consists of instruction execution in machine code, but a program consists of instruction in any programming language.
  • A process is a dynamic object, but a program is a static object.
  • Process resides in main memory, but program resides in secondary memory.
  • The span of time for the process is limited, but the span of time for the program is unlimited.
  • A process is an active entity and a program is a passive entity.

Process States in Operating Systems

New: The process is being created.
Running: The process is being executed.
Waiting: The process is waiting for some event to occur.
Ready: The process is waiting to be assigned to a processor.
Terminate: The process has finished execution.

New -> Ready: The operating system creates a process. And prepares the process to be executed, then the operating system moves the process into the ready queue.

Ready -> Running: When it is time to select a process to run, the operating system selects one of the jobs for the ready queue and moves the processes from the ready state to the running state.

Running -> Terminated: When the execution of a process has been completed then the operating system terminates that process from the running state. Sometimes the operating system terminates the processes for some other reasons also including time limit exceeded memory unavailable access violation, protection error, I/O failure, data misuse, and so on.

Running -> Ready: When the time slot for the processor expires or if the processor receives an interrupt signal, then the operating system shifts the running process to the ready state.

For example, process P1 is executed by the processor, and at that time processor, P2 generates an interrupt signal to the processor. Then the processor compares the priorities of processes P1 and P2. If P1>P2 then the processor continues executing P1. Otherwise, the processor switches to process P2, and process P1 is moved to the ready state.

Running -> Waiting: A process is put into the waiting state if the process needs an event to occur, or if an I/O device is to read. The operating system does not provide the I/O or event immediately then the process is moved to the waiting state by the operating system.

Waiting -> Ready: A process in the blocked state is moved to the ready state when the event for which it has been waiting occurs.

For example, if a process in the running state needs an I/O device, then the process is moved to a wait or blocked state. When the I/O device is provided by the operating system, the process moved to the ready state from the waiting or blocked state.


Process Creation

When a user initiates to execute a program, the operating system creates a process to represent the execution of this program. The creation of executable programs includes many steps for this, consider the figure.

OS_process_creation

The source module (or) source code (A program written in programming languages) is translated into object program (or) object modules with the help of a translator (Compiler). The relocatable object module is converted to absolute programs by the linker. The absolute program is converted to executable programs by loaders. Then the processor executes this program. A program in execution is said to be a process.

The process consists of the machine code image of the program in memory plus PCB (Process Control Block).


Process Termination

The process of termination from the running state includes so many causes. Generally, the process terminates when execution is finished. Some other causes are:

  • Time slot expired: When the process execution doesn’t complete within the “Time Quantum”. Then the process terminated from the running state. The CPU picks the next job in the ready queue to execute.
  • Memory violation: If a process needs more memory than the available memory, then the process is terminated from the running state.
  • I/O failure: A process needs an I/O operation at the time of execution, but the I/O device isn’t available at that time. Then the process moved into the waiting state. The operating system doesn’t provide the I/O device, even if the process resides in the waiting state, then the process is terminated.
  • Parent termination: When the “Parent Process” terminated, the child process also terminated automatically. The parent process has the authority to terminate any of its children.
  • Parent request: If the parent process requests the child process the termination, then the child process is terminated automatically.
  • Invalid instruction: If a process has illegal instructions and the CPU failed to execute those instructions, then the process is terminated.

Operation on Process

Systems that manage processes must be able to perform certain operations with the process. The operation on process includes:

  1. Create a Process
  2. Destroy a Process
  3. Resume a Process
  4. Change the process priority
  5. Block of Process
  6. Wakeup a Process
  7. Dispatch a Process
  8. Enable a process to communicate with other processes

Concurrent Process

Two processes are Serial if the execution of one must be complete before the execution of the other can be started. If the two processes are said to be concurrent, they are not serial, and their execution can overlap in time.

OS_conncurrent

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top