SlideShare a Scribd company logo
3.1 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
UNIT 2
PROCESS MANAGEMENT
Objectives:
 To introduce the notion of a process -- a program in
execution, which forms the basis of all computation
 To describe the various features of processes, including
scheduling, creation and termination, and communication
 To explore interprocess communication using shared
memory and message passing
 To describe communication in client-server systems
3.2 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Concept
 Process – a program in execution.
 A process is the unit of work in a modern time-sharing system.
 Multiple parts
 The program code, also called text section
 Stack containing temporary data
 Function parameters, return addresses, local variables
 Data section containing global variables
 Heap containing memory dynamically allocated during run time
3.3 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process in Memory
3.4 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Concept (Cont.)
 Program is passive entity stored on disk (executable file),
process is active
 Program becomes process when executable file loaded into
memory
 Execution of program started via GUI mouse clicks, command
line entry of its name, etc
 One program can be several processes
 Consider multiple users executing the same program
3.5 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Control Block (PCB)
Information associated with each process
(also called task control block)
 Process ID(PID) – integer
 Priority Number
 Program counter – location of
instruction to next execute
 Memory-allocation – memory allocated
to the process
 I/O status information – I/O devices
allocated to process, list of open files
 List of open files
 Accounting information – CPU used,
clock time elapsed since start, time
limits
 CPU registers – contents of all process-
centric registers
 Process state – running, waiting, etc
3.6 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process State
 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 processor
 terminated: The process has finished execution
3.7 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Diagram of Process State
3.8 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
 OS maintains ready queue – ready
processes(priority order)
 Blocked queue – Blocked processes
(unordered)
 Dispatching- The process of assigning a
processor to the first process on the ready
list by dispatcher
3.9 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
 Exit reasons:
1. completing operation
2.due to unrecoverable error
 H/W interrupting clock – to avoid
continuous usage
3.10 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
State transition Remarks
1.Ready to running Process is dispatched
2.Running to ready Process time slice expires
3.Running to blocked When a process blocks
4.Blocked to ready After the I/O event
5.Ready to exit Parent process terminates child
process
6.Running to exit After completion of task
3.11 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Suspended process
 I/O device is slower than Processor
 Suspended state:
- Blocked to suspended state(disk)
Characteristics:
1.The process cannot execute immediately
2.The process may or may not be waiting for
an event
3.By parent submission
3.12 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Operating System
Process Scheduling:
 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.Each device has own queue
 Process is moved between the various queues.
3.13 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
3.14 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Schedulers
 Long-term scheduler (or job scheduler):
- selects which processes should be brought into
the ready queue.
 Medium term scheduler
- Part of swapping function.
- Removes process from memory for I/O
- May lead to suspended state (disk).
3.15 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
3.16 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
 Short-term scheduler (or CPU scheduler
or Dispatcher )
– selects which process should be
executed next and allocates CPU for
execution.
- Moves process from ready queue to
processor
3.17 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
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.
 Reasons:
1.Multitasking 2.Interrupt handling 3.User
and kernel mode switching
3.18 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
3.19 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
OPERATIONS ON PROCESSES
Process Creation:
 OS creates new process with specified
attributes and identifiers.
 The creating process is called a parent
process, where as the new processes are
called the children of that process
3.20 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
 Parent process creates children processes, which, in
turn create other processes, forming a tree of processes.
 Resource sharing
 Parent and children share all resources.
 Children share subset of parent’s resources.
 Execution
 Parent and children execute concurrently.
 Parent waits until children terminate.
3.21 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Creation (Cont.)
 UNIX examples
 fork system call creates new process
Void main()
{
fork();
}
 execve system call used after a fork to
replace the process’ memory space with a
new program.
3.22 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Termination
 Process executes last statement and asks the operating
system to decide it (exit).
 Parent may terminate execution of children processes
(abort).
1.Normal completion of operation
2.Memory is not available
3.Time slice expired
4.Parent termination
5.Failure of I/O
6.Request from parent process
7.Misuse of access rights
3.23 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
COOPERATING PROCESSES
 A process is independent if it cannot affect
or be affected by the other processes
executing in the system.
 A process is cooperating if it can affect or
be affected by the other processes
executing in the system.
3.24 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Reason for cooperating processes
 Information sharing
 Computation speedup (By exec sub
tasks parallel)
 Modularity(dividing the system functions
into separate processes or threads)
 Convenience
3.25 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Producer – Consumer Problem:
 A producer process produces information
that is consumed by a consumer process.
 For example, a print program produces
characters that are consumed by the
printer driver. A compiler may produce
assembly code, which is consumed by an
assembler.
3.26 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
 To allow producer and consumer
processes to run concurrently, we must
have available a buffer of items that can
be filled by the producer and emptied by
the consumer.
 unbounded-buffer: places no practical limit
on the size of the buffer.
 bounded-buffer : assumes that there is a
fixed buffer size.
3.27 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Interprocess Communication (IPC)
 Operating systems provide the means for
cooperating processes to communicate with
each other via an inter process communication
(PC) facility.
 IPC provides a mechanism to allow processes to
communicate and to synchronize their actions.
 IPC is best provided by a message passing
system.
COPY
3.28 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
 Inter process communication is achieved
through,
1. Shared Memory - memory shared among
the processes
2. Message Passing – communicate and to
synchronize their actions
IPC facility provides two operations:
 send(message)
 receive(message)
3.29 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
(a) Message passing. (b) shared memory
3.30 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Basic Structure:
 If processes P and Q want to
communicate, they must send messages
to and receive messages from each other,
a communication link must exist between
them.
 Physical implementation of the link is done
through a hardware bus , network etc,
3.31 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Methods
1.Direct Communication:
 Processes must name each other explicitly:
 send (P, message) – send a message to process P
 receive(Q, message) – receive a message from
process Q
 Properties of communication link
 Links are established automatically.
 A link is associated with exactly one pair of
communicating processes.
 Between each pair there exists exactly one link.
 The link may be unidirectional, but is usually bi-
directional.
3.32 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
2.Indirect Communication
 Messages are directed and received from mailboxes (also referred to as ports).
 Each mailbox has a unique id.
 Processes can communicate only if they share a mailbox.
 Properties of communication link
 Link established only if processes share a common mailbox
 A link may be associated with many processes.
 Each pair of processes may share several communication links.
 Link may be unidirectional or bi-directional.
 Operations
 create a new mailbox
 send and receive messages through mailbox
 destroy a mailbox
3.33 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
3.Buffering:
 Queue of messages attached to the link;
implemented in one of three ways.
1. Zero capacity – 0 messages
Sender must wait for receiver.
2. Bounded capacity – finite length of n
messages, Sender must wait if link full.
3. Unbounded capacity – infinite length
Sender never waits.
3.34 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
4.Synchronization:
Message passing may be either blocking or non-
blocking.
 1. Blocking Send - The sender blocks itself till the
message sent by it is received by the receiver.
 2. Non-blocking Send - The sender does not block
itself after sending the message but continues with
its normal operation.
 3. Blocking Receive - The receiver blocks itself
until it receives the message.
 4. Non-blocking Receive – The receiver does not
block itself.
3.35 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
THREADS – OVERVIEW
 A thread is the basic unit of CPU utilization.
 It is sometimes called as a lightweight process.
 It consists of a thread ID, a program counter, a register
set and a stack.
3.36 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
User thread and Kernel threads
User threads:
-It uses user space for thread scheduling
-Transparent to OS
- Created by run time libraries and cannot
execute privileged instructions
- smaller and faster
EX:POSIX pthreads, Mach C-threads
3.37 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
 Kernel thread
-Thread management is done by kernel.
-OS supports KLT.
- Threads are constructed and controlled
by system calls.
Ex: Windows 95/98/NT
3.38 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Multithreading models
 In many applications,user level threads
are mapped with kernel level threads.
1.One to one
2.Many to one
3.Many to many
3.39 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
One to One
 One user level thread is mapped with one
kernel level thread.
 For 3 UT,Kernel creates 3 KT
 Ex:Windows 95/XP,LINUX
3.40 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Many to one
 Many user level threads are mapped with
one kernel level thread.
 Single thread of control
Ex: Green threads for SOLARIS
3.41 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Many to many
 Many user level threads map with many
kernel level threads
 M-to-N thread mapping
3.42 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
THREADING ISSUES:
1. fork() and exec() system calls.
2. Thread cancellation.
3. Signal handling
4. Thread pools
5. Thread specific data
3.43 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
CPU SCHEDULING
 Selects one process among the processes in
memory that are ready to execute, and
allocates the CPU to one of them.
 CPU scheduling is the basis of multi-
programmed operating systems.
CPU-I/O Burst Cycle:
 Process execution consists of a cycle of CPU
execution and I/O wait.
 Process execution begins with a CPU burst.
3.44 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
3.45 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
CPU Scheduler:
 Whenever the CPU becomes idle, the
operating system must select one of the
processes in the ready queue to be executed.
 The selection process is carried out by the
short-term scheduler (or CPU scheduler).
 The ready queue is not necessarily a first-in,
first-out (FIFO) queue. It may be a FIFO
queue, a priority queue, a tree, or simply an
unordered linked list.
3.46 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Preemptive Scheduling:
A scheduling method that interrupts the processing of a process and
transfers the CPU to another process.
CPU scheduling decisions may take place under the following four
circumstances:
1. When a process switches from the running state to the waiting
state.
2. When a process switches from the running state to the ready
state.
3. When a process switches from the waiting state to the ready
state.
4. When a process terminates.
 Under 1 & 4 scheduling scheme is non preemptive.
 Otherwise the scheduling scheme is preemptive.
3.47 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Non-Preemptive Scheduling:
 In non preemptive scheduling, once the
CPU has been allocated a process, the
process keeps the CPU until it releases
the CPU either by termination or by
switching to the waiting state.
3.48 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Dispatcher:
 The dispatcher is the module that gives control
of the CPU to the process selected by the short-
term scheduler.
This function involves:
1. Switching context
2. Switching to user mode
3. Jumping to the proper location in the user
program to restart that program.
3.49 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
SCHEDULING CRITERIA
1. CPU utilization: The CPU should be kept as busy
as possible. CPU utilization may range from 0 to
100 percent.
2. Throughput: It is the number of processes
completed per time unit.
3. Turnaround time: The interval from the time of
submission of a process to the time of completion
is the turnaround time.
Turnaround time is the sum of the periods spent
waiting to get into memory, waiting in the ready
queue, executing on the CPU, and doing I/O.
3.50 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
4. Waiting time: Waiting time is the sum of
the periods spent waiting in the ready
queue.
5. Response time: It is the amount of time it
takes to start responding, but not the time
that it takes to output that response.
3.51 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Multilevel Queue Scheduling
 It partitions the ready queue into several
separate queues .
 The processes are permanently assigned to
one queue
3.52 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Multilevel Feedback Queue Scheduling
 It allows a process to move between queues.
 If a process uses too much CPU time, it will
be moved to a lower-priority queue.
3.53 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
MULTIPLE-PROCESSOR SCHEDULING
 CPU scheduling more complex when multiple CPUs
are available
 Homogeneous processors within a multiprocessor
 Asymmetric multiprocessing – only one processor
accesses the system data structures.
 Symmetric multiprocessing (SMP) – each processor
is self-scheduling, all processes in common ready
queue, or each has its own private queue of ready
processes
3.54 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
 Load Balancing
One or more processors may sit idle
while other processors have high workloads,
along with lists of processes awaiting the
CPU.
Load balancing attempts to keep the
workload evenly distributed across all
processors in an SMP system.
3.55 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
REAL-TIME CPU SCHEDULING
 Composed of the scheduler, clock and the
processing hardware elements.
 Soft real-time systems- provide no guarantee
as to when a critical real-time process will be
scheduled.
 They guarantee only that the process will be
given preference over noncritical processes.
 Hard real-time systems - have stricter
requirements. A task must be serviced by its
deadline,service after the deadline has expired.
3.56 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
CASE STUDY: LINUX SCHEDULING
 the Completely Fair Scheduler (CFS) became
the default Linux scheduling algorithm.
 Scheduling in the Linux system is based on
scheduling classes.
 Each class is assigned a specific priority.
 Equally divides the CPU time among all the
processes
3.57 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
CFS PERFORMANCE :
 The Linux CFS scheduler provides an
efficient algorithm for selecting which task
to run next.
 Each runnable task is placed in a red-
black tree—a balanced binary search tree
whose key is based on the value of
vruntime
3.58 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition

More Related Content

Similar to OS UNIT2.ppt

Lecture_Process.ppt
Lecture_Process.pptLecture_Process.ppt
Lecture_Process.ppt
RahulKumarYadav87
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
Sami Mughal
 
Processes
ProcessesProcesses
Processes
K Gowsic Gowsic
 
process management.ppt
process management.pptprocess management.ppt
process management.ppt
ShubhamGoel184057
 
Operating System
Operating SystemOperating System
Operating System
Indhu Periys
 
ch3 s ppt
ch3 s                                  pptch3 s                                  ppt
ch3 s ppt
DhruvilSTATUS
 
cs8493 - operating systems unit 2
cs8493 - operating systems unit 2cs8493 - operating systems unit 2
cs8493 - operating systems unit 2
SIMONTHOMAS S
 
ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 c...
ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 c...ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 c...
ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 c...
SanjeevKumarSinha13
 
Ch3 processes
Ch3 processesCh3 processes
Ch3 processes
Ankit Dubey
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
SonaliAjankar
 
Week03-Ch3-Process Concept.pptx.gfhgvjhg
Week03-Ch3-Process Concept.pptx.gfhgvjhgWeek03-Ch3-Process Concept.pptx.gfhgvjhg
Week03-Ch3-Process Concept.pptx.gfhgvjhg
alianwar88
 
ch3-lect7.pptx
ch3-lect7.pptxch3-lect7.pptx
ch3-lect7.pptx
haroon451422
 
Ch3OperSys
Ch3OperSysCh3OperSys
Ch3OperSys
Dwight Sabio
 
OperatingSystemChp3
OperatingSystemChp3OperatingSystemChp3
OperatingSystemChp3
Dwight Sabio
 
14712-l4.pptx
14712-l4.pptx14712-l4.pptx
14712-l4.pptx
KAVINKUMARVS1
 
ch03.pptx
ch03.pptxch03.pptx
ch03.pptx
SHIKHAARYA26
 
ch3_LU6_LU7_Lecture_1691052564579.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptxch3_LU6_LU7_Lecture_1691052564579.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptx
AKumaraGuru
 
ch3.pptx
ch3.pptxch3.pptx
ch3.pptx
HuyNguyn660008
 
Chapter 3 Processes (1)Operating systems.pptx
Chapter 3  Processes (1)Operating systems.pptxChapter 3  Processes (1)Operating systems.pptx
Chapter 3 Processes (1)Operating systems.pptx
RoyHanzala
 

Similar to OS UNIT2.ppt (20)

Lecture_Process.ppt
Lecture_Process.pptLecture_Process.ppt
Lecture_Process.ppt
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
Processes
ProcessesProcesses
Processes
 
process management.ppt
process management.pptprocess management.ppt
process management.ppt
 
Operating System
Operating SystemOperating System
Operating System
 
ch3 s ppt
ch3 s                                  pptch3 s                                  ppt
ch3 s ppt
 
cs8493 - operating systems unit 2
cs8493 - operating systems unit 2cs8493 - operating systems unit 2
cs8493 - operating systems unit 2
 
ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 c...
ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 c...ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 c...
ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 ch3 c...
 
Ch3 processes
Ch3 processesCh3 processes
Ch3 processes
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
Week03-Ch3-Process Concept.pptx.gfhgvjhg
Week03-Ch3-Process Concept.pptx.gfhgvjhgWeek03-Ch3-Process Concept.pptx.gfhgvjhg
Week03-Ch3-Process Concept.pptx.gfhgvjhg
 
ch3-lect7.pptx
ch3-lect7.pptxch3-lect7.pptx
ch3-lect7.pptx
 
Ch3OperSys
Ch3OperSysCh3OperSys
Ch3OperSys
 
OperatingSystemChp3
OperatingSystemChp3OperatingSystemChp3
OperatingSystemChp3
 
14712-l4.pptx
14712-l4.pptx14712-l4.pptx
14712-l4.pptx
 
ch03.pptx
ch03.pptxch03.pptx
ch03.pptx
 
ch3_LU6_LU7_Lecture_1691052564579.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptxch3_LU6_LU7_Lecture_1691052564579.pptx
ch3_LU6_LU7_Lecture_1691052564579.pptx
 
ch3.pptx
ch3.pptxch3.pptx
ch3.pptx
 
Chapter 3 Processes (1)Operating systems.pptx
Chapter 3  Processes (1)Operating systems.pptxChapter 3  Processes (1)Operating systems.pptx
Chapter 3 Processes (1)Operating systems.pptx
 

More from DHANABALSUBRAMANIAN

unit 2.ppt
unit 2.pptunit 2.ppt
Unit --3.ppt
Unit --3.pptUnit --3.ppt
Unit --3.ppt
DHANABALSUBRAMANIAN
 
Unit 4.ppt
Unit 4.pptUnit 4.ppt
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit -- 5.ppt
Unit -- 5.pptUnit -- 5.ppt
Unit -- 5.ppt
DHANABALSUBRAMANIAN
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit - 5.ppt
Unit - 5.pptUnit - 5.ppt
Unit - 5.ppt
DHANABALSUBRAMANIAN
 
Unit - 3.ppt
Unit - 3.pptUnit - 3.ppt
Unit - 3.ppt
DHANABALSUBRAMANIAN
 
unit -1.ppt
unit -1.pptunit -1.ppt
unit -1.ppt
DHANABALSUBRAMANIAN
 
Unit -2.ppt
Unit -2.pptUnit -2.ppt
Unit -2.ppt
DHANABALSUBRAMANIAN
 
OS UNIT1.pptx
OS UNIT1.pptxOS UNIT1.pptx
OS UNIT1.pptx
DHANABALSUBRAMANIAN
 
OS Unit5.pptx
OS Unit5.pptxOS Unit5.pptx
OS Unit5.pptx
DHANABALSUBRAMANIAN
 
OS UNIT4.pptx
OS UNIT4.pptxOS UNIT4.pptx
OS UNIT4.pptx
DHANABALSUBRAMANIAN
 
OS UNIT3.pptx
OS UNIT3.pptxOS UNIT3.pptx
OS UNIT3.pptx
DHANABALSUBRAMANIAN
 

More from DHANABALSUBRAMANIAN (15)

unit 2.ppt
unit 2.pptunit 2.ppt
unit 2.ppt
 
Unit --3.ppt
Unit --3.pptUnit --3.ppt
Unit --3.ppt
 
Unit 4.ppt
Unit 4.pptUnit 4.ppt
Unit 4.ppt
 
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit 1.ppt
 
Unit -- 5.ppt
Unit -- 5.pptUnit -- 5.ppt
Unit -- 5.ppt
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit 5.ppt
 
Unit - 5.ppt
Unit - 5.pptUnit - 5.ppt
Unit - 5.ppt
 
Unit - 3.ppt
Unit - 3.pptUnit - 3.ppt
Unit - 3.ppt
 
unit -1.ppt
unit -1.pptunit -1.ppt
unit -1.ppt
 
Unit -2.ppt
Unit -2.pptUnit -2.ppt
Unit -2.ppt
 
OS UNIT1.pptx
OS UNIT1.pptxOS UNIT1.pptx
OS UNIT1.pptx
 
OS Unit5.pptx
OS Unit5.pptxOS Unit5.pptx
OS Unit5.pptx
 
OS UNIT4.pptx
OS UNIT4.pptxOS UNIT4.pptx
OS UNIT4.pptx
 
OS UNIT3.pptx
OS UNIT3.pptxOS UNIT3.pptx
OS UNIT3.pptx
 

Recently uploaded

欧洲杯下注-欧洲杯下注押注官网-欧洲杯下注押注网站|【​网址​🎉ac44.net🎉​】
欧洲杯下注-欧洲杯下注押注官网-欧洲杯下注押注网站|【​网址​🎉ac44.net🎉​】欧洲杯下注-欧洲杯下注押注官网-欧洲杯下注押注网站|【​网址​🎉ac44.net🎉​】
欧洲杯下注-欧洲杯下注押注官网-欧洲杯下注押注网站|【​网址​🎉ac44.net🎉​】
andagarcia212
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
Payaamvohra1
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
The basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptxThe basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptx
heathfieldcps1
 
How to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRMHow to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRM
Celine George
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
Kalna College
 
8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity
RuchiRathor2
 
Opportunity scholarships and the schools that receive them
Opportunity scholarships and the schools that receive themOpportunity scholarships and the schools that receive them
Opportunity scholarships and the schools that receive them
EducationNC
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
Celine George
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
The Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teachingThe Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teaching
Derek Wenmoth
 
220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science
Kalna College
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
heathfieldcps1
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
Post init hook in the odoo 17 ERP Module
Post init hook in the  odoo 17 ERP ModulePost init hook in the  odoo 17 ERP Module
Post init hook in the odoo 17 ERP Module
Celine George
 

Recently uploaded (20)

欧洲杯下注-欧洲杯下注押注官网-欧洲杯下注押注网站|【​网址​🎉ac44.net🎉​】
欧洲杯下注-欧洲杯下注押注官网-欧洲杯下注押注网站|【​网址​🎉ac44.net🎉​】欧洲杯下注-欧洲杯下注押注官网-欧洲杯下注押注网站|【​网址​🎉ac44.net🎉​】
欧洲杯下注-欧洲杯下注押注官网-欧洲杯下注押注网站|【​网址​🎉ac44.net🎉​】
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
The basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptxThe basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptx
 
How to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRMHow to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRM
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
 
8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity
 
Opportunity scholarships and the schools that receive them
Opportunity scholarships and the schools that receive themOpportunity scholarships and the schools that receive them
Opportunity scholarships and the schools that receive them
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
The Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teachingThe Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teaching
 
220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
 
Post init hook in the odoo 17 ERP Module
Post init hook in the  odoo 17 ERP ModulePost init hook in the  odoo 17 ERP Module
Post init hook in the odoo 17 ERP Module
 

OS UNIT2.ppt

  • 1. 3.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition UNIT 2 PROCESS MANAGEMENT Objectives:  To introduce the notion of a process -- a program in execution, which forms the basis of all computation  To describe the various features of processes, including scheduling, creation and termination, and communication  To explore interprocess communication using shared memory and message passing  To describe communication in client-server systems
  • 2. 3.2 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Process Concept  Process – a program in execution.  A process is the unit of work in a modern time-sharing system.  Multiple parts  The program code, also called text section  Stack containing temporary data  Function parameters, return addresses, local variables  Data section containing global variables  Heap containing memory dynamically allocated during run time
  • 3. 3.3 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Process in Memory
  • 4. 3.4 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Process Concept (Cont.)  Program is passive entity stored on disk (executable file), process is active  Program becomes process when executable file loaded into memory  Execution of program started via GUI mouse clicks, command line entry of its name, etc  One program can be several processes  Consider multiple users executing the same program
  • 5. 3.5 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Process Control Block (PCB) Information associated with each process (also called task control block)  Process ID(PID) – integer  Priority Number  Program counter – location of instruction to next execute  Memory-allocation – memory allocated to the process  I/O status information – I/O devices allocated to process, list of open files  List of open files  Accounting information – CPU used, clock time elapsed since start, time limits  CPU registers – contents of all process- centric registers  Process state – running, waiting, etc
  • 6. 3.6 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Process State  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 processor  terminated: The process has finished execution
  • 7. 3.7 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Diagram of Process State
  • 8. 3.8 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  OS maintains ready queue – ready processes(priority order)  Blocked queue – Blocked processes (unordered)  Dispatching- The process of assigning a processor to the first process on the ready list by dispatcher
  • 9. 3.9 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  Exit reasons: 1. completing operation 2.due to unrecoverable error  H/W interrupting clock – to avoid continuous usage
  • 10. 3.10 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition State transition Remarks 1.Ready to running Process is dispatched 2.Running to ready Process time slice expires 3.Running to blocked When a process blocks 4.Blocked to ready After the I/O event 5.Ready to exit Parent process terminates child process 6.Running to exit After completion of task
  • 11. 3.11 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Suspended process  I/O device is slower than Processor  Suspended state: - Blocked to suspended state(disk) Characteristics: 1.The process cannot execute immediately 2.The process may or may not be waiting for an event 3.By parent submission
  • 12. 3.12 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Operating System Process Scheduling:  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.Each device has own queue  Process is moved between the various queues.
  • 13. 3.13 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
  • 14. 3.14 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Schedulers  Long-term scheduler (or job scheduler): - selects which processes should be brought into the ready queue.  Medium term scheduler - Part of swapping function. - Removes process from memory for I/O - May lead to suspended state (disk).
  • 15. 3.15 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
  • 16. 3.16 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  Short-term scheduler (or CPU scheduler or Dispatcher ) – selects which process should be executed next and allocates CPU for execution. - Moves process from ready queue to processor
  • 17. 3.17 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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.  Reasons: 1.Multitasking 2.Interrupt handling 3.User and kernel mode switching
  • 18. 3.18 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
  • 19. 3.19 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition OPERATIONS ON PROCESSES Process Creation:  OS creates new process with specified attributes and identifiers.  The creating process is called a parent process, where as the new processes are called the children of that process
  • 20. 3.20 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  Parent process creates children processes, which, in turn create other processes, forming a tree of processes.  Resource sharing  Parent and children share all resources.  Children share subset of parent’s resources.  Execution  Parent and children execute concurrently.  Parent waits until children terminate.
  • 21. 3.21 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Process Creation (Cont.)  UNIX examples  fork system call creates new process Void main() { fork(); }  execve system call used after a fork to replace the process’ memory space with a new program.
  • 22. 3.22 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Process Termination  Process executes last statement and asks the operating system to decide it (exit).  Parent may terminate execution of children processes (abort). 1.Normal completion of operation 2.Memory is not available 3.Time slice expired 4.Parent termination 5.Failure of I/O 6.Request from parent process 7.Misuse of access rights
  • 23. 3.23 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition COOPERATING PROCESSES  A process is independent if it cannot affect or be affected by the other processes executing in the system.  A process is cooperating if it can affect or be affected by the other processes executing in the system.
  • 24. 3.24 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Reason for cooperating processes  Information sharing  Computation speedup (By exec sub tasks parallel)  Modularity(dividing the system functions into separate processes or threads)  Convenience
  • 25. 3.25 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Producer – Consumer Problem:  A producer process produces information that is consumed by a consumer process.  For example, a print program produces characters that are consumed by the printer driver. A compiler may produce assembly code, which is consumed by an assembler.
  • 26. 3.26 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  To allow producer and consumer processes to run concurrently, we must have available a buffer of items that can be filled by the producer and emptied by the consumer.  unbounded-buffer: places no practical limit on the size of the buffer.  bounded-buffer : assumes that there is a fixed buffer size.
  • 27. 3.27 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Interprocess Communication (IPC)  Operating systems provide the means for cooperating processes to communicate with each other via an inter process communication (PC) facility.  IPC provides a mechanism to allow processes to communicate and to synchronize their actions.  IPC is best provided by a message passing system. COPY
  • 28. 3.28 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  Inter process communication is achieved through, 1. Shared Memory - memory shared among the processes 2. Message Passing – communicate and to synchronize their actions IPC facility provides two operations:  send(message)  receive(message)
  • 29. 3.29 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition (a) Message passing. (b) shared memory
  • 30. 3.30 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Basic Structure:  If processes P and Q want to communicate, they must send messages to and receive messages from each other, a communication link must exist between them.  Physical implementation of the link is done through a hardware bus , network etc,
  • 31. 3.31 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Methods 1.Direct Communication:  Processes must name each other explicitly:  send (P, message) – send a message to process P  receive(Q, message) – receive a message from process Q  Properties of communication link  Links are established automatically.  A link is associated with exactly one pair of communicating processes.  Between each pair there exists exactly one link.  The link may be unidirectional, but is usually bi- directional.
  • 32. 3.32 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 2.Indirect Communication  Messages are directed and received from mailboxes (also referred to as ports).  Each mailbox has a unique id.  Processes can communicate only if they share a mailbox.  Properties of communication link  Link established only if processes share a common mailbox  A link may be associated with many processes.  Each pair of processes may share several communication links.  Link may be unidirectional or bi-directional.  Operations  create a new mailbox  send and receive messages through mailbox  destroy a mailbox
  • 33. 3.33 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 3.Buffering:  Queue of messages attached to the link; implemented in one of three ways. 1. Zero capacity – 0 messages Sender must wait for receiver. 2. Bounded capacity – finite length of n messages, Sender must wait if link full. 3. Unbounded capacity – infinite length Sender never waits.
  • 34. 3.34 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 4.Synchronization: Message passing may be either blocking or non- blocking.  1. Blocking Send - The sender blocks itself till the message sent by it is received by the receiver.  2. Non-blocking Send - The sender does not block itself after sending the message but continues with its normal operation.  3. Blocking Receive - The receiver blocks itself until it receives the message.  4. Non-blocking Receive – The receiver does not block itself.
  • 35. 3.35 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition THREADS – OVERVIEW  A thread is the basic unit of CPU utilization.  It is sometimes called as a lightweight process.  It consists of a thread ID, a program counter, a register set and a stack.
  • 36. 3.36 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition User thread and Kernel threads User threads: -It uses user space for thread scheduling -Transparent to OS - Created by run time libraries and cannot execute privileged instructions - smaller and faster EX:POSIX pthreads, Mach C-threads
  • 37. 3.37 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  Kernel thread -Thread management is done by kernel. -OS supports KLT. - Threads are constructed and controlled by system calls. Ex: Windows 95/98/NT
  • 38. 3.38 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Multithreading models  In many applications,user level threads are mapped with kernel level threads. 1.One to one 2.Many to one 3.Many to many
  • 39. 3.39 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition One to One  One user level thread is mapped with one kernel level thread.  For 3 UT,Kernel creates 3 KT  Ex:Windows 95/XP,LINUX
  • 40. 3.40 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Many to one  Many user level threads are mapped with one kernel level thread.  Single thread of control Ex: Green threads for SOLARIS
  • 41. 3.41 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Many to many  Many user level threads map with many kernel level threads  M-to-N thread mapping
  • 42. 3.42 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition THREADING ISSUES: 1. fork() and exec() system calls. 2. Thread cancellation. 3. Signal handling 4. Thread pools 5. Thread specific data
  • 43. 3.43 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition CPU SCHEDULING  Selects one process among the processes in memory that are ready to execute, and allocates the CPU to one of them.  CPU scheduling is the basis of multi- programmed operating systems. CPU-I/O Burst Cycle:  Process execution consists of a cycle of CPU execution and I/O wait.  Process execution begins with a CPU burst.
  • 44. 3.44 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
  • 45. 3.45 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition CPU Scheduler:  Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed.  The selection process is carried out by the short-term scheduler (or CPU scheduler).  The ready queue is not necessarily a first-in, first-out (FIFO) queue. It may be a FIFO queue, a priority queue, a tree, or simply an unordered linked list.
  • 46. 3.46 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Preemptive Scheduling: A scheduling method that interrupts the processing of a process and transfers the CPU to another process. CPU scheduling decisions may take place under the following four circumstances: 1. When a process switches from the running state to the waiting state. 2. When a process switches from the running state to the ready state. 3. When a process switches from the waiting state to the ready state. 4. When a process terminates.  Under 1 & 4 scheduling scheme is non preemptive.  Otherwise the scheduling scheme is preemptive.
  • 47. 3.47 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Non-Preemptive Scheduling:  In non preemptive scheduling, once the CPU has been allocated a process, the process keeps the CPU until it releases the CPU either by termination or by switching to the waiting state.
  • 48. 3.48 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Dispatcher:  The dispatcher is the module that gives control of the CPU to the process selected by the short- term scheduler. This function involves: 1. Switching context 2. Switching to user mode 3. Jumping to the proper location in the user program to restart that program.
  • 49. 3.49 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition SCHEDULING CRITERIA 1. CPU utilization: The CPU should be kept as busy as possible. CPU utilization may range from 0 to 100 percent. 2. Throughput: It is the number of processes completed per time unit. 3. Turnaround time: The interval from the time of submission of a process to the time of completion is the turnaround time. Turnaround time is the sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU, and doing I/O.
  • 50. 3.50 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 4. Waiting time: Waiting time is the sum of the periods spent waiting in the ready queue. 5. Response time: It is the amount of time it takes to start responding, but not the time that it takes to output that response.
  • 51. 3.51 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Multilevel Queue Scheduling  It partitions the ready queue into several separate queues .  The processes are permanently assigned to one queue
  • 52. 3.52 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Multilevel Feedback Queue Scheduling  It allows a process to move between queues.  If a process uses too much CPU time, it will be moved to a lower-priority queue.
  • 53. 3.53 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition MULTIPLE-PROCESSOR SCHEDULING  CPU scheduling more complex when multiple CPUs are available  Homogeneous processors within a multiprocessor  Asymmetric multiprocessing – only one processor accesses the system data structures.  Symmetric multiprocessing (SMP) – each processor is self-scheduling, all processes in common ready queue, or each has its own private queue of ready processes
  • 54. 3.54 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  Load Balancing One or more processors may sit idle while other processors have high workloads, along with lists of processes awaiting the CPU. Load balancing attempts to keep the workload evenly distributed across all processors in an SMP system.
  • 55. 3.55 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition REAL-TIME CPU SCHEDULING  Composed of the scheduler, clock and the processing hardware elements.  Soft real-time systems- provide no guarantee as to when a critical real-time process will be scheduled.  They guarantee only that the process will be given preference over noncritical processes.  Hard real-time systems - have stricter requirements. A task must be serviced by its deadline,service after the deadline has expired.
  • 56. 3.56 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition CASE STUDY: LINUX SCHEDULING  the Completely Fair Scheduler (CFS) became the default Linux scheduling algorithm.  Scheduling in the Linux system is based on scheduling classes.  Each class is assigned a specific priority.  Equally divides the CPU time among all the processes
  • 57. 3.57 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition CFS PERFORMANCE :  The Linux CFS scheduler provides an efficient algorithm for selecting which task to run next.  Each runnable task is placed in a red- black tree—a balanced binary search tree whose key is based on the value of vruntime
  • 58. 3.58 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition