Overview of Process Management

Process

  • The process is a program that's executing.
  • When a program is loaded into the memory, it becomes a process.
  • Each instance of the program is a different process.

Process Memory

Each process has process memory. Process Memory is divided as follows.

Stack:

It stores temporary data like function parameters, returns addresses, and local variables. The stack grows and shrink.

Heap:

It allocates memory, which may be processed during its run time.

Data:

It contains constants.

Text:

It includes the current activity, Contains Program Code.

Context Switching

Kernel switching from one process to another process is known as Context Switching.

Reasons for Context Switching

  • A process with high priority arrives for execution.
  • Running process requires I/O resources in the system and many more ...

Process State

When a process executes, it passes through different states. These stages may differ in different operating systems.

New:

The initial state when a process is first started/created.

Ready:

The process is waiting to be assigned to a processor.

Running:

The process is chosen by the CPU for execution and the instructions within the process are executed.

Waiting:

Process wait for a resource, such as waiting for user input, or waiting for a file to become available.

Terminated:

When a process finishes its execution, it comes in the termination state.

Process Control Block

A Process Control Block is a data structure maintained by the Operating System for every process. Context of a process represented in the PCB. The PCB is identified by an integer process identifier (PID).

CPU Scheduling

  • Process of determining which process will own CPU for execution while another process is on hold.
  • The aim of CPU scheduling is to make the system efficient, fast, and fair.
  • Whenever the CPU becomes idle, the OS must select one of the processes in the ready queue to be executed.

CPU Scheduling Algorithms

The selection process is carried out by the CPU scheduler using different algorithms they are

  • First Come First Serve (FCFS)
  • Shortest-Job-First (SJF) Scheduling
  • Priority Scheduling
  • Round Robin Scheduling and many more ...

CPU Scheduling Terminology

Arrival Time:

Time at which the process arrives in the ready queue.

Completion Time:

Time at which process completes its execution.

Burst Time:

The time required by a process for CPU execution.

Turnaround Time:

The total amount of time spent by a process in the system.

Turnaround Time = Completion Time – Arrival Time

Waiting Time:

Amount of time spent by a process in the ready queue.

Waiting Time = Turnaround Time – Burst Time

First Come First Serve

  • A process that requests the CPU first gets the CPU allocated first.
  • A process that arrived in the ready queue earlier will be executed earlier.

Example:

ProcessArrival TimeBurst Time
P1021
P213
P326
P432

The process p1, p2, p3, and p4 are schedule with First Come First Serve are as follows.

So, the Completion time, Turnaround time, Waiting time of the process(p1, p2, p3 & p4) are as follows.

ProcessArrival TimeBurst TimeCompletion TimeTurn Around TimeWaiting Time
P102121210
P213242320
P326302822
P432322927
Average Waiting Time = (0 + 20 + 22 + 27)/4 = 17.25
Average Turnaround Time = (21 + 23 + 28 + 29)/4 = 25.25

Shortest Job First

Shortest Job First(SJF) scheduling works on the process with the shortest burst time or duration first.

ProcessArrival TimeBurst Time
P1021
P213
P326
P402

The shortest job first scheduling for process p1, p2, p3, and p4 is as follows.

Priority Scheduling

Priority Scheduling Algorithm works on the process with the higher priority. Processes with the same priority are executed in an FCFS manner.

ProcessArrival TimeBurst TimePriority
P10212
P2131
P3264
P4323

The processes(p1, p2, p3, and p4) scheduled based on Priority Scheduling are as follows.

Round Robin Scheduling

In Round Robin Scheduling a fixed time is allotted to each process called Time Slice for execution. Once a process is executed for the given time period then another process executes for the given time period.

Example:

ProcessArrival TimeBurst Time
P1021
P213
P326
P432

Suppose the Time Slice is 5 units and the process p1, p2, p3, and p4 are scheduled in Round Robin Scheduling are as follows.

Inter Process Communication

IPC is a mechanism, where the OS allows various processes to communicate with each other.

Communication can be done through:

  • Shared Memory
  • Message passing

Shared Memory

  • A particular region of memory is shared between the cooperating process.
  • Exchanging information by reading and writing data to this shared region.

Message Passing

  • Communication takes place by exchanging messages directly between the cooperating process.

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form