Operating System Presentation

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

OPERATING

SYSTEM
PROCESS MANAGEMENT
01 02 03

04 05 06
Introduction
A Program does nothing unless its instructions are executed by a CPU. A program
in execution is called a process. In order to accomplish its task, process needs the
computer resources.
There may exist more than one process in the system which may require the same
resource at the same time. Therefore, the operating system has to manage all the
processes and the resources in a convenient and efficient way.
Some resources may need to be executed by one process at one time to maintain the
consistency otherwise the system can become inconsistent and deadlock may occur.
DEFINITION OF PROCESS

PROCESS

The running state of a program is


known as a process

Operating system has the right to


create, schedule, and terminate a
process.
SECTIONS IN A PROCESS

TEXT DATA
Holds the current activities represented Holds the global variables
by the value of Program Counter

STACK HEAP
Holds temporary data such as local variables, Dynamically allocate memory to
functional parameters, return addresses, etc. process during runtime
PROCESS CONTROL BLOCK (PCB)

• While creating a process the operating system performs several


operations. To identify the processes, it assigns a process
identification number (PID) to each process. As the operating system
supports multi-programming, it needs to keep track of all the
processes.
• For this task, the process control block (PCB) is used to track the
process’s execution status. Each block of memory contains
information about the process state, program counter, stack pointer,
status of opened files, scheduling algorithms, etc.
• All these information is required and must be saved when the process
is switched from one state to another.
• When the process makes a transition from one state to another, the
operating system must update information in the process’s PCB.
• A process control block (PCB) contains information about the
process, i.e. registers, quantum, priority, etc. The process table is an
array of PCB’s, that means logically contains a PCB for all of the
current processes in the system.
PROCESS CONTROL BLOCK (PCB)
● Pointer – It is a stack pointer which is required to be saved when the process is switched from one state to another to retain the
current position of the process.
● Process state – It stores the respective state of the process.
● Process number – Every process is assigned with a unique id known as process ID or PID which stores the process identifier.
● Program counter – It stores the counter which contains the address of the next instruction that is to be executed for the process.
● Register – These are the CPU registers which includes: accumulator, base, registers and general purpose registers.
● Memory limits – This field contains the information about memory management system used by operating system. This may
include the page tables, segment tables etc.
● Open files list – This information includes the list of files opened for a process.

● The process control block stores the register content also known as execution content of the processor when it was blocked from
running. This execution content architecture enables the operating system to restore a process’s execution context when the
process returns to the running state.
● When the process makes a transition from one state to another, the operating system updates its information in the process’s PCB.
● The operating system maintains pointers to each process’s PCB in a process table so that it can access the PCB quickly.
PROCESS ATTRIBUTES
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.

PROCESS STATE
The Attributes of the process are used by The Process, from its creation to the completion, goes
the Operating System to create the through various states which are new, ready, running and
process control block (PCB) for each of waiting.
them. This is also called context of the
process. 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.
PROCESS ATTRIBUTES
PRIORITY
Every process has its own priority. The process
with the highest priority among the processes LIST OF OPEN FILES
gets the CPU first. This is also stored on the
process control block. During the Execution, Every process uses some
files which need to be present in the main
memory. OS also maintains a list of open files in
the PCB.

LIST OF OPEN DEVICES


PROGRAM COUNTER
OS also maintain the list of all open devices
A program counter stores the address of the last
which are used during the execution of the
instruction of the process on which the process was
suspended. The CPU uses this address when the execution process.
of this process is resumed.
PROCESS STATES
NEW
The process, from its creation to completion,
passes through various states. The minimum
number of states is five. A program which is going to be picked up by
The names of the states are not standardized the OS into the main memory is called a
although the process may be in one of the new process.
following states during execution.

RUNNING READY
One of the processes from the ready state will The processes which are ready for the
be chosen by the OS depending upon the execution and reside in the main memory
scheduling algorithm. Hence, If we have are called ready state processes. There can
n processors in the system then we can be many processes present in the ready
have n processes running simultaneously. state.
PROCESS STATES
BLOCK OR WAIT TERMINATION
When a process waits for a certain When a process finishes its execution, it
resource to be assigned or for the comes in the termination state. All the
input from the user then the OS context of the process (Process Control
move this process to the block or Block) will also be deleted the process
wait state and assigns the CPU to the will be terminated by the Operating
other processes. system.

SUSPEND READY
SUSPEND WAIT
A process in the ready state, which is moved
to secondary memory from the main Uses the process which was performing I/O
memory due to lack of the resources operation and lack of main memory
(mainly primary memory) is called in caused them to move to secondary
the suspend ready state. memory. When work is finished, it may
go to suspend ready.
PROCESS OPERATIONS
• CREATION
Once the process is created, it will be ready and come into the ready queue (main memory) and will be
ready for the execution.

• SCHEDULING
Out of the many processes present in the ready queue, the Operating system chooses one process and
start executing it. Selecting the process which is to be executed next, is known as scheduling.

• EXECUTION
Once the process is scheduled for the execution, the processor starts executing it. Process may come to
the blocked or wait state during the execution then in that case the processor starts executing the other
processes.

• DELETION/KILLING
Once the purpose of the process gets over then the OS will kill the process. The Context of the process
(PCB) will be deleted and the process gets terminated by the Operating system.
CONTEXT SWITCHING
• DEFINITION
• The Context switching is a technique or method used by the operating system to switch a process
from one state to another to execute its function using CPUs in the system.
• When switching perform in the system, it stores the old running process's status in the form of
registers and assigns the CPU to a new process to execute its tasks. While a new process is running
in the system, the previous process must wait in a ready queue.
• The execution of the old process starts at that point where another process stopped it. It defines the
characteristics of a multitasking operating system in which multiple processes shared the same CPU
to perform multiple tasks without the need for additional processors in the system.

• Steps for Context Switching


• There are several steps involves in context switching of the processes. The following diagram
represents the context switching of two processes, P1 to P2, when an interrupt, I/O needs, or
priority-based process occurs in the ready queue of PCB.
CONTEXT SWITCHING
• The following steps are taken when switching Process P1 to Process 2:
• First, the context switching needs to save the state of process P1 in the form of the
program counter and the registers to the PCB (Program Counter Block), which is in
the running state.
• Now update PCB1 to process P1 and moves the process to the appropriate queue,
such as the ready queue, I/O queue and waiting queue.
• After that, another process gets into the running state, or we can select a new
process from the ready state, which is to be executed, or the process has a high
priority to execute its task.
• Now, we have to update the PCB (Process Control Block) for the selected process
P2. It includes switching the process state from ready to running state or from
another state like blocked, exit, or suspend.
• If the CPU already executes process P2, we need to get the status of process P2 to
resume its execution at the same time point where the system interrupt occurs.
PROCESS SCHEDULING
• LONG TERM SCHEDULAR
• Long term scheduler is also known as job scheduler. It chooses the processes from the pool (secondary memory) and
keeps them in the ready queue maintained in the primary memory.
• Long Term scheduler mainly controls the degree of Multiprogramming. The purpose of long term scheduler is to
choose a perfect mix of IO bound and CPU bound processes among the jobs present in the pool.
• If the job scheduler chooses more IO bound processes then all of the jobs may reside in the blocked state all the time
and the CPU will remain idle most of the time. This will reduce the degree of Multiprogramming. Therefore, the Job
of long term scheduler is very critical and may affect the system for a very long time.

• SHORT TERM SCHEDULAR


• Short term scheduler is also known as CPU scheduler. It selects one of the Jobs from the ready queue and dispatch to
the CPU for the execution.
• A scheduling algorithm is used to select which job is going to be dispatched for the execution. The Job of the short
term scheduler can be very critical in the sense that if it selects job whose CPU burst time is very high then all the
jobs after that, will have to wait in the ready queue for a very long time.
• This problem is called starvation which may arise if the short term scheduler makes some mistakes while selecting
the job.
PROCESS SCHEDULING

• MEDIUM TERM SCHEDULAR


• Medium term scheduler takes care of the swapped out processes. If the running state processes needs some IO time
for the completion then there is a need to change its state from running to waiting.
• Medium term scheduler is used for this purpose. It removes the process from the running state to make room for the
other processes. Such processes are the swapped out processes and this procedure is called swapping. The medium
term scheduler is responsible for suspending and resuming the processes.
• It reduces the degree of multiprogramming. The swapping is necessary to have a perfect mix of processes in the ready
queue.
PROCESS QUEUES
• DEFINITION
• The Operating system manages various types of queues for each of the process states. The PCB
related to the process is also stored in the queue of the same state. If the Process is moved from one
state to another state then its PCB is also unlinked from the corresponding queue and added to the
other state queue in which the transition is made.

• JOB QUEUE
• In starting, all the processes get stored in the job queue. It is maintained in the secondary memory. The long term
scheduler (Job scheduler) picks some of the jobs and put them in the primary memory.

• READY QUEUE
• Ready queue is maintained in primary memory. The short term scheduler picks the job from the ready queue and
dispatch to the CPU for the execution.

• WAITING QUEUE
• When the process needs some IO operation in order to complete its execution, OS changes the state of the process
from running to waiting. The context (PCB) associated with the process gets stored on the waiting queue which will
be used by the Processor when the process finishes the IO.
CPU SCHEDULING
• In the Uniprogrammming systems like MS DOS, when a process waits for any I/O operation to be done, the CPU
remains idol. This is an overhead since it wastes the time and causes the problem of starvation. However, In
Multiprogramming systems, the CPU doesn't remain idle during the waiting time of the Process and it starts
executing other processes. Operating System has to define which process the CPU will be given.
• In Multiprogramming systems, the Operating system schedules the processes on the CPU to have the maximum
utilization of it and this procedure is called CPU scheduling.

• NEED
• In Multiprogramming, if the long term scheduler picks more I/O bound processes then most of the time, the CPU
remains idol. The task of Operating system is to optimize the utilization of resources.
• If most of the running processes change their state from running to waiting then there may always be a possibility of
deadlock in the system. Hence to reduce this overhead, the OS needs to schedule the jobs to get the optimal
utilization of CPU and to avoid the possibility to deadlock.
INTER PROCESS COMMUNICATION
• DEFINITION
• Inter-process communication is used for exchanging useful information between numerous threads
in one or more processes (or programs).
• In general, Inter Process Communication is a type of mechanism usually provided by the operating
system (or OS).
• The main aim or goal of this mechanism is to provide communications in between several
processes.

• ROLE OF SYNCHRONIZATION
• It is one of the essential parts of inter process communication. Typically, this is provided by inter-process
communication control mechanisms, but sometimes it can also be controlled by communication processes.
• These are the following methods that used to provide the synchronization:
• Mutual Exclusion
• Semaphore
• Barrier
• Spinlock
INTER PROCESS COMMMUNICATION DIFFERENT APPROACHES
INTER PROCESS COMMUNICATION
• DIFFERENT APPROACHES
• These are a few different approaches for Inter- Process Communication:
• Pipes
• Shared Memory
• Message Queue
• Direct Communication
• Indirect communication
• Message Passing
• FIFO
• OTHER APPROACHES
• Socket
• File
• Signal
• NEED
• It helps to speedup modularity
• Computational
• Convenience
CASE STUDY
THANK YOU

You might also like