You are on page 1of 21

Process

Management
Learning Objectives:

• Differentiate what is Program and Process


• Understand what is Process Management in
Operating System
• Define the PCB and its Attributes
Overview:

Process management in OS entails completing a variety


of responsibilities, including process development,
scheduling, impasse management, and process
termination. The operating system is in charge of
overseeing all of the system's ongoing functions. By
executing tasks like resource allocation and process
scheduling, the operating system manages processes.
When a process runs on a computer, both the machine's
RAM and CPU are used. Additionally, the operating
system must coordinate the many computer operations.
What is a Program?
• A program is a piece of code that can be as simple as a single
line or as complex as millions of lines.
• A programmer usually develops a computer program in a
programming language.

What is a Process?
• A process is the instance of computer program that is being
executed.
• It performs all task that is present in the program.
• When a program is running, it is called as process.
COMPILER

Hello.class Secondary
(PRPGRAM) Memory
Hello.java

Secondary
Memory
Main
CPU Memory
Process management
❑ It is an important part of the operating system. It
allows you to control the way your computer runs by
managing the currently active processes. This includes
ending processes that are no longer needed, setting
process priorities, and more.
❑ There are several processes in the process management
system that use the same shared resources. As a
result, the operating system must efficiently and
effectively manage all activities and structures.
Process management
❑To preserve consistency, some elements may need to be executed
by one operation at a time. Otherwise, the system might be
inconsistent and deadlock may develop.
In terms of Process Management, the operating system is in
charge of the following task.
• Process and schedule on CPU.
• Both user and system processes can be created and
deleted.
• Process are suspended and resumed.
• Providing synchronization method for processes.
• Providing communication mechanism for processes.
Process Structure
When a program becomes a process, it is structured. The
structure can be divided into four parts and theses are:

STACK

HEAP

TEXT

CODE
• CODE – stores a code which will be executed.
• DATA – this consist Static Variable and Global Variable.
o Static Variable is the variable which is allocated statically.
– that is what we defined as variable while writing the
program.
– they remain until complete run of program.
– Value assigned to static variable is preserved.
o Global Variable has global scope.
– It can be accessed anywhere in the program.
• HEAP – free space available in memory.
• STACK – used for local variables which we normally declare in a
program. It also used to store method of function parameters or
return address.
The following are the
attributes of PCB.

Process Control Block (PCB) Process ID

Program Counter
The operating system control’s a process
by a block called Process Control Block. For Process State

each process, operating system maintains the Priority


data structure which keeps track of complete Registers
information about the process. This data List of open files
structure or record is called PCB. I/O devices
Protection
………
• Process ID – When a process is created, a unique id is assigned
to the process which is used for unique identification of the
process in the system.
• Program Counter – A program counter stores the address of the
last instruction of the process on which the process was
suspended. The CPU uses this address when the execution of
this process is resumed.
• Process State – There are a few possible states a process goes
through during execution, from its creation to the completion,
goes through various states which are new, ready, running and
waiting.

• Priority – Every process has its own priority. The process with
the highest priority among the processes gets the CPU first. This
is also stored on the process control block.
• General Purpose Registers – Every process has its own set of
registers which are used to hold the data which is generated
during the execution of the process.

• List of open files – files which need to be present in the main


memory. OS also maintains a list of open files in the PCB.

• I/O devices – this are the input and output devices need for the
execution of the process.

• Protection – is present in PCB in order to protect the order of


the processes and not getting interchange.
Process State
• New State –This is the first state of the process life cycle. When
process creation is taking place, the process is in a new state
• Ready State –When the process creation gets completed, the
process comes into a ready state. During this state, the process
is loaded into the main memory and will be placed in the queue
of processes which are waiting for the CPU allocation.
• Running State – Whenever the CPU is allocated to the process
from the ready queue, the process state changes to Running.
• Block or Wait State – When the process is executing the
instructions, the process might require carrying out a few tasks
which might not require CPU. If the process requires performing
Input-Output task or the process needs some resources which
are already acquired by other processes, during such conditions
process is brought back into the main memory, and the state is
changed to Blocking or Wait for the state. Process is placed in
the queue of processes that are in waiting or block state in the
main memory.
• Terminated or Completed – When the entire set of instructions
is executed and the process is completed. The process is
changed to terminated or completed state. During this state the
PCB of the process is also deleted.
Process State
It’s possible that the process is waiting or blocked state can
be swapped out to secondary memory. Let’s understand in which
state process in waiting or block state will go.

• Suspend Ready – whenever the main memory is full, the


process which is in a ready state is swapped out from main
memory to secondary memory. The process is in a ready state
when goes through the transition of moving from main memory
to secondary memory, the state of that process is changed to
Suspend Ready state. Once the main memory will have enough
space for the process, the process will be brought back to the
main memory and will be in a ready state.
Process State
• Suspend Wait or Suspend Blocked – Whenever the
process that is in waiting for state or block state in
main memory gets to swap out to secondary memory
due to main memory being completely full, the process
state is changed to Suspend wait or Suspend blocked
state.
Conclusion
✓ Program under execution is called process.
✓ Process goes through different states throughout the
life cycle which are called process states.
✓ New, Ready, Running, Waiting or Block, Terminated or
Completed, Suspend ready, and Suspend wait or
blocked are different states which process might go
during the life cycle.
✓ The state of the process is stored in Process Control
Block (PCB).
QUESTION?

You might also like