0% found this document useful (0 votes)
15 views

OS-Process-Management

Uploaded by

Sourav Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

OS-Process-Management

Uploaded by

Sourav Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Operating System

Topperworld.in

Process management

What is a Process?

• Process is the execution of a program that performs the actions


specified in that program.
• It can be defined as an execution unit where a program runs.
• The OS helps you to create, schedule, and terminates the processes
which is used by CPU.
• A process created by the main process is called a child process.
• Process operations can be easily controlled with the help of PCB
(Process Control Block).
• You can consider it as the brain of the process, which contains all the
crucial information related to processing like process id, priority, state,
CPU registers, etc.

What is Process Management?

• Process management involves various tasks like creation, scheduling,


termination of processes, and a dead lock.
• Process is a program that is under execution, which is an important part
of modern-day operating systems.
• The OS must allocate resources that enable processes to share and
exchange information.
• It also protects the resources of each process from other methods and
allows synchronization among processes.

©Topperworld
Operating System

• It is the job of OS to manage all the running processes of the system. It


handles operations by performing tasks like process scheduling and
such as resource allocation.

ProcessArchitecture:

Here, is an Architecture diagram of the Process


• Stack: The Stack stores temporary data like function parameters,
returns addresses, and local variables.
• Heap: Allocates memory, which may be processed during its run time.
• Data: It contains the variable.
• Text:Text Section includes the current activity, which is represented by
the value of the Program Counter.
Characteristic of process:
Process has the following attributes.
• Process Id: A unique identifier assigned by the operating system.
• Process State: Can be ready, running, etc.

©Topperworld
Operating System

• CPU registers: Like the Program Counter (CPU registers must be saved
and restored when a process is swapped in and out of the CPU)
• Accounts information: Amount of CPU used for process execution,
time limits, execution ID, etc
• I/O status information: For example, devices allocated to the process,
open files, etc
• CPU scheduling information: For example, Priority (Different
processes may have different priorities, for example, a shorter
process assigned high priority in the shortest job first scheduling).

Process State:
• Process is a program at the time of execution.
• A process is more than a program code.
• It includes the program counter, the process stack, and the contents of
the process register, etc.
• When a process executes, it changes the state.
• Generally, the state of the process determined by the current activity
of the process.
• In Operating System, Each process may be in one of the following
states:

©Topperworld
Operating System

Fig: Process State


Process Scheduling Algorithms:
• Process scheduling algorithms determine which processes are selected
from the ready queue and granted CPU time for execution.
• They ensure that each process receives an appropriate amount of CPU
time they prevent starvation.
• They play a critical role in managing the transitions between these
process states, ensuring efficient resource utilization, fair allocation,
and optimal system performance.

©Topperworld
Operating System

Process scheduling algorithms are divided into two categories:


✓ Preemptive scheduling.
✓ Non-preemptive scheduling.
Preemptive scheduling algorithms:
In preemptive scheduling, a running process can be forcefully interrupted
and moved out of the CPU before its completion if a higher-priority process
becomes ready or if its time slice (quantum) expires. Preemptive scheduling
algorithms are:
Round robin (RR):
Multi-level queue scheduling (MLQS).
Let's study these preemptive scheduling algorithms in detail.
Round robin (RR)
• In RR scheduling, each process is assigned a fixed time slice
(quantum).
• If a process does not complete within its quantum, it is preempted
and moved to the end of the ready queue, allowing the next process
to execute.
• Let's have a look at an example of an RR scheduling algorithm with 5
processes: P1, P2, P3, P4, and P5, arriving at different times and a
fixed quantum slice of 4s.

©Topperworld
Operating System

Wait time of each process is as follows :

Multi-level queue scheduling (MLQS):


• Multi-level queue scheduling (MLQS) is a process scheduling algorithm
that divides processes into multiple priority-based queues.
• Each queue has its own scheduling policy, such as First Come, First
Served (FCFS), round robin (RR), or another suitable algorithm.
• Processes are initially assigned to a specific queue based on their
priority or specific characteristics.
• Higher-priority queues are serviced first, and if there are no processes
in the higher-priority queues, lower-priority queues are given CPU time.
In the diagram below, let's visualize the structure of a multi-level queue
scheduler

©Topperworld
Operating System

Non-preemptive scheduling algorithms:


• Non-preemptive scheduling algorithms are process scheduling
techniques where a running process cannot be interrupted until it
voluntarily releases the CPU.
Here are some examples of non-preemptive scheduling algorithms:
First Come, First Served (FCFS)
Shortest Job First (SJF)
Let's study these preemptive scheduling algorithms in depth.
First Come, First Served (FCFS):
• FCFS scheduling is a non-preemptive algorithm where processes are
executed in the order they arrive.
• Once a process starts executing, it continues until it completes or
enters a waiting state voluntarily.
• FCFS scheduling algorithm acts similarly to a queue.
• Let's have a look at an example of an FCFS scheduling algorithm with 4
processes: P0, P1, P2, and P3, arriving at different times.
FCFS example:

©Topperworld
Operating System

Shortest Job Next (SJN):


• This is also known as shortest job first, or SJF
• This is a non-preemptive, pre-emptive scheduling algorithm.
• Best approach to minimize waiting time.
• Easy to implement in Batch systems where required CPU time is known
in advance.
• Impossible to implement in interactive systems where required CPU
time is not known.
• The processer should know in advance how much time process will
take.
Given: Table of processes, and their Arrival time, Execution time

©Topperworld
Operating System

©Topperworld

You might also like