Chapter-III Process Management

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

OPERATING SYSTEMS

OSY - 22516

UNIT-III
PROCESS MANAGEMENT

Mr. Naresh A. Kamble


POINTS TO BE COVERED
• Introduction to PROCESS
• Process Scheduling
• Inter Process Communication (IPC)
• Threads
• Execute Process Commands
PROCESS
• An operating system executes a variety of programs:

– Batch system – jobs

– Time-shared systems – user programs or tasks

• Process – a program in execution; process execution must progress in


sequential fashion

• A process includes:

– program counter

– stack

– data section
PROCESS
• PROCESS IN MEMORY
PROCESS STATES
• PROCESS STATES

• As a process executes, it changes state

– new: The process is being created

– running: Instructions are being executed

– waiting: The process is waiting for some event to occur

– ready: The process is waiting to be assigned to a process

– terminated: The process has finished execution


PROCESS STATES
• Process State Diagram (PST)
PROCESS CONTROL BLOCK
• Process control Block

• Each process is represented in the OS by process control


block.

• Also called as task control block.


SWITCH CPU FROM PROCESS TO PROCESS
PROCESS CONTROL BLOCK
• Process state: The process may be new, ready, running,
waiting, halted etc.
• Program counter: It indicates the address of the next
instruction to be executed for this process.
• CPU registers: They includes accumulators, index registers,
stack pointers and general purpose registers. Can save the
interrupted program & resume afterwards.
• CPU-Scheduling information: Process priority information.
• Memory-Management information: Management of memory
consumption.
• Accounting information: Amount of CPU & real time used.
• I/O status information: List of input & output devices.
PROCESS SCHEDULING
• Process scheduling focus on multiprogramming.

• User can interact with each process running on system & can
know the current status (completed, paused or suspended )

• For this purpose process scheduler is used which select an


available process from set of several process.
PROCESS SCHEDULING
• Process Scheduling Queues
• Job queue – set of all processes in the system

• Ready queue – set of all processes residing in main memory,


ready and waiting to execute

• Device queues – set of processes waiting for an I/O device

• Processes migrate among the various queues


PROCESS SCHEDULING QUEUES
Queuing diagram representation of process scheduling
PROCESS SCHEDULING
• SCHEDULERS

• LONG TERM SCHEDULER

• MEDIUM TERM SCHEDULER

• SHORT TERM SCHEDULER


PROCESS SCHEDULING
• LONG TERM SCHEDULER
• It is also called a job scheduler. A long-term scheduler
determines which programs are admitted to the system for
processing.

• It selects processes from the queue and loads them into


memory for execution.

• Process loads into the memory for CPU scheduling.


PROCESS SCHEDULING
• MEDIUM TERM SCHEDULER

• Medium-term scheduling is a part of swapping. It removes the processes from the

memory. It reduces the degree of multiprogramming. The medium-term scheduler

is in-charge of handling the swapped out-processes.

• A running process may become suspended if it makes an I/O request. A suspended

processes cannot make any progress towards completion. In this condition, to

remove the process from memory and make space for other processes, the

suspended process is moved to the secondary storage. This process is

called swapping, and the process is said to be swapped out or rolled out.

Swapping may be necessary to improve the process mix.


PROCESS SCHEDULING
• SHORT TERM SCHEDULER

• It is also called as CPU scheduler. Its main objective is to increase


system performance in accordance with the chosen set of criteria. It
is the change of ready state to running state of the process. CPU
scheduler selects a process among the processes that are ready to
execute and allocates CPU to one of them.

• Short-term schedulers, also known as dispatchers, make the


decision of which process to execute next. Short-term schedulers
are faster than long-term schedulers.
Addition of medium-term scheduling to the queuing diagram.
PROCESS SCHEDULING
• CONTEXT SWITCH

• When CPU switches to another process, the system must save


the state of the old process and load the saved state for the
new process.

• Context-switch time is overhead; the system does no useful


work while switching.

• Time dependent on hardware support.


INTER PROCESS COMMUNICATION
• COOPERATING PROCESS
• Independent process cannot affect or be affected by the execution of
another process

• Cooperating process can affect or be affected by the execution of another


process

• Advantages of process cooperation

– Information sharing

– Computation speed-up

– Modularity

– Convenience
INTER PROCESS COMMUNICATION
• Cooperating processes requires interprocess communication (IPC)
mechanism that will allow them to exchange data and information.

• There are two fundamental models of interprocess communication

• 1. SHARED MEMORY SYSTEM

• 2. MESSAGE PASSING SYSTEM


COMMUNICATIONS MODELS

MESSAGE PASSING SYSTEM SHARED MEMORY SYSTEM


INTER PROCESS COMMUNICATION
• SHARED MEMORY SYSTEM
• Interprocess communication using shared memory requires
communicating processes to establish a region of shared memory.

• Shared memory resides in the address space of the process creating the
shared memory region segment.

• Other process that wish to communicate using shared memory segment


must attach it to their address space.

• They can exchange information by reading & writing data in shared area.
INTER PROCESS COMMUNICATION
• MESSAGE PASSSING SYSTEM
• There are 3 types of message passing

• 1. Direct communication

– send (Q, message) – send a message to process Q (destination)

– receive(P, message) – receive a message from process P (source)

SOURCE P MESSAGE
SOURCE Q
INTER PROCESS COMMUNICATION
• MESSAGE PASSSING SYSTEM
• 2. Indirect communication

• Messages are directed and received from mailboxes (also referred to as


ports)

• send(Q, message) – send a message to mailbox Q (destination)

• receive(Q, message) – receive a message from mailbox Q (source)

SOURCE P Q’s SOURCE Q


MAILBOX

MESSAGE
INTER PROCESS COMMUNICATION
• MESSAGE PASSSING SYSTEM

• 3. Synchronization

• Message passing may be either blocking or non-blocking

• Blocking is considered synchronous

– Blocking send has the sender block until the message is received

– Blocking receive has the receiver block until a message is available

• Non-blocking is considered asynchronous

– Non-blocking send has the sender send the message and continue

– Non-blocking receive has the receiver receive a valid message or null


THREADS
• INTRODUCTION

• A thread is a single sequence stream within the process.

• They are also called as LIGHTWEIGHT processes and has


some properties of processes.

• Each thread belongs exactly to one process.

• In multithreading, process can consist of many threads.

• Threads can share common data so that they do not need to


use interprocess communication.

• Each thread has its own Thread Control Block (TCB).


THREADS
• TYPES OF THREADS

TYPES OF THREADS

USER LEVEL THREADS KERNEL LEVEL THREADS


THREADS
• USER LEVEL THREADS

• In this implementation, kernel is unaware of the thread.

• These thread package operates entirely in user space.

• Java language supports threading package.

• Thread management includes


– Creation and termination of threads

– Message and data passing between the threads.

– Scheduling thread for execution.

– Thread synchronization etc.


THREADS
• KERNEL LEVEL THREADS

• In this threads are implemented in kernel space.

• All the thread management activities are carried out in kernel


space.

• Kernel threads requires more time to create and manage than


the user threads.
THREADS
• DEFINITION
• A process is a program that performs a single thread of
execution.
• Single and Multithreaded Processes.
THREADS
• MULTITHREADING MODELS
• MANY-TO-ONE MODEL
THREADS
• ONE-TO-ONE MODEL
THREADS
• MANY-TO-MANY MODEL

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy