Process Management in Operating System

 

Process Management in Operating System

Process Management - Process

Process

A process is a program in execution. A process is a more than program code which is sometimes known as a text section. it also includes the current activity , as represented by the value of the program counter and the contents of the processor registers.  A process generally also includes the process stack, which contains temporary data and a data section  which contains Global variables. A process may also include a heap, which is memory that is dynamically allocated during process runtime .



Process State

New: The new process is being created.

Running: Instructions are executed

Waiting: The process is waiting for some event.

Ready: The process is ready to be assigned to a CPU.

Terminated: The process has finished execution.

Process control Block

Each process is represented in the operating system by a process control block.It contains a lot of information related to the process.

  1. Process state.
  2. Program counter.
  3. CPU register.
  4. CPU scheduling information.
  5. Memory management information.
  6. I/O status information.

Process scheduler

 Scheduler selects the job and assigns it to the CPU.

Long term Scheduler: This type of scheduler selects the process from the process pool and assigns it to  main memory for execution.

Short term scheduler: scheduler process from ready queue and assign to CPU for execution.

Medium term scheduler:

 Scheduling is a part of swapping. It removes the process from the memory. It reduces the degree of multiprogramming. Swapped out processes can be re-introduced into memory and its execution can be continued where it left off. This scheme is known as swapping. The process is swapped out and is later swapped in and is handled by a medium term scheduler. 

Context Switching: 

When interrupts occur , the system needs to save the current context of the process running on the CPU so that it can restore that context when its processing is done, essentially suspending the process and then resuming it. The context is represented by a program control block of the process. It includes the values of CPU registers, the process state and memory management information .

Process creation:

 a process may create several new processes. The creating process is called the parent process and new processes are called children of that process.

When a process creates a new process, two possibilities for execution exist.

  1. The parent continues to execute concurrently with its children.
  2. The parent waits until some or all of its children have terminated.

 A new process is created by the fork() system call. The new process consists of a copy of the address space of the original process. Both processes (the parent and child) continue execution at the instruction after fork(), with one difference the return code for the fork() is zero for new new child process, whereas the (non-zero) process identifier of the child is returned to the parent .



Example:  a process executes the following segment of code.

fork();

fork();

fork();

How many processes are created?

Post a Comment

0 Comments