SlideShare a Scribd company logo
Processes Management
Operating System Concepts
 Process Concept
 Process Scheduling
 Operations on Processes
 Cooperating Processes
 Interprocess Communication
 Communication in Client-Server Systems
Process Concept
Operating System Concepts
 An operating system executes a variety of
programs:
 Batch system – jobs
 Time-shared systems – user programs or tasks
 Textbook uses the terms job and process
almost interchangeably.
 Process – a program in execution; process
execution must progress in sequential
fashion.
 A process includes:
 program counter
 stack
 data section
Process Concept
Operating System Concepts
Process State
Operating System Concepts
 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.
Diagram of Process State
Operating System Concepts
Process Control Block (PCB)
Operating System Concepts
Information associated with each process.
 Process state
 Program counter
 CPU registers
 CPU scheduling information
 Memory-management information
 Accounting information
 I/O status information
Process Control Block (PCB)
Operating System Concepts
Context Switching
Operating System Concepts
 Switching the CPU to another process
requires a state save of the current process
and a state restore of a different process.
This task is known as context switching.
 The Context of a process is saved in PCB.
 Context Switching time is pure overhead.
 Its speed varies from machine to machine
depending upon memory speed and the
number of register.
CPU Switch From Process to
Process
Operating System Concepts
Process Scheduling Queues
Operating System Concepts
 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.
 All the queues are implemented by linked list.
 Each queue has a header contains pointers to
the first and final PCBs.
 In turn each PCB includes a pointer field that
points to the next PCB
 Process migration between the various queues.
Ready Queue And Various I/O Device Queues
Operating System Concepts
Representation of Process
Scheduling
Operating System Concepts
Schedulers
Operating System Concepts
 Long-term scheduler (or job scheduler) – selects
which processes should be brought into the
ready queue.
 Short-term scheduler (or CPU scheduler) –
selects which process should be executed next
and allocates CPU.
Schedulers (Cont.)
Operating System Concepts
 Short-term scheduler is invoked very frequently
(milliseconds)  (must be fast).
 Long-term scheduler is invoked very infrequently
(seconds, minutes)  (may be slow).
 The long-term scheduler controls the degree of
multiprogramming.
 Processes can be described as either:
 I/O-bound process – spends more time doing I/O than computations,
many short CPU bursts.
 CPU-bound process – spends more time doing computations; few
very long CPU bursts.
Addition of Medium Term Scheduling
Operating System Concepts
Process Creation
Operating System Concepts
 Parent process create 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.
 Parent and child share no resources.
 Execution
 Parent and children execute concurrently.
 Parent waits until children terminate.
Process Creation (Cont.)
Operating System Concepts
 Address space
 Child duplicate of parent.
 Child has a program loaded into it.
 UNIX examples
 fork system call creates new process
 exec system call used after a fork to replace the process’ memory
space with a new program.
System
Operating System Concepts
Process Termination
Operating System Concepts
 Process executes last statement and asks the
operating system to delete it (exit).
 Output data from child to parent (via wait).
 Process’ resources are deallocated by operating system.
 Parent may terminate execution of children
processes (abort).
 Child has exceeded allocated resources.
 Task assigned to child is no longer required.
 Parent is exiting.
 Operating system does not allow child to continue if its parent
terminates.
 Cascading termination.
Interprocess Communication
(IPC)
Operating System Concepts
Cooperating Processes:
 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
Producer-Consumer Problem
Shared-Memory System
Operating System Concepts
 Paradigm for cooperating processes, producer
process produces information that is consumed
by a consumer process.
 unbounded-buffer places no practical limit on the size of the buffer.
 bounded-buffer assumes that there is a fixed buffer size.
Bounded-Buffer – Shared-Memory Solution
Operating System Concepts
 Shared data
#define BUFFER_SIZE 10
Typedef struct {
. . .
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
in points to the next free position
out points to the first full position
In==out (buffer is empty)
((in +1)%BUFFER_SIZE))==out(buffer full)
 Solution is correct, but can only use
BUFFER_SIZE-1 elements
Bounded-Buffer – Producer Process
Operating System Concepts
item nextProduced;
while (1) {
while (((in + 1) % BUFFER_SIZE) == out)
; /* do nothing */
buffer[in] = nextProduced;
in = (in + 1) % BUFFER_SIZE;
}
Bounded-Buffer – Consumer Process
Operating System Concepts
item nextConsumed;
while (1) {
while (in == out)
; /* do nothing */
nextConsumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
}
Message Passing Systems
Operating System Concepts
 Mechanism for processes to communicate and
to synchronize their actions without sharing
memory.
 Message system – processes communicate with
each other without resorting to shared variables.
 IPC facility provides two operations:
 send(message) – message size fixed or variable
 receive(message)
 If P and Q wish to communicate, they need to:
 establish a communication link between them
 exchange messages via send/receive
 Implementation of communication link
 physical (e.g., shared memory, hardware bus)
 logical (e.g., logical properties)
Implementation Questions
Operating System Concepts
 How are links established?
 Can a link be associated with more than two
processes?
 How many links can there be between every pair
of communicating processes?
 What is the capacity of a link?
 Is the size of a message that the link can
accommodate fixed or variable?
 Is a link unidirectional or bi-directional?
Direct Communication
Operating System Concepts
 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.
Indirect Communication
Operating System Concepts
 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.
Indirect Communication
Operating System Concepts
 Operations
 create a new mailbox
 send and receive messages through mailbox
 destroy a mailbox
 Primitives are defined as:
send(A, message) – send a message to
mailbox A
receive(A, message) – receive a message
from mailbox A
Indirect Communication
Operating System Concepts
 Mailbox sharing
 P1, P2, and P3 share mailbox A.
 P1, sends; P2 and P3 receive.
 Who gets the message?
 Solutions
 Allow a link to be associated with at most two processes.
 Allow only one process at a time to execute a receive operation.
 Allow the system to select arbitrarily the receiver. Sender is notified
who the receiver was.
Synchronization
Operating System Concepts
 Message passing may be either blocking or non-
blocking.
 Blocking is considered synchronous
 Non-blocking is considered asynchronous
 send and receive primitives may be either
blocking or non-blocking.
Buffering
Operating System Concepts
 Queue of messages attached to the link;
implemented in one of three ways.
1. Zero capacity – 0 messages
Sender must wait for receiver (rendezvous).
2. Bounded capacity – finite length of n messages
Sender must wait if link full.
3. Unbounded capacity – infinite length
Sender never waits.
Threads
Operating System Concepts
 A thread is a basic unit of CPU utilization; it
comprises a thread ID, a register set, and a stack.
 The thread shares its code section , data section,
and other resources with other threads belongs to
the same process.
 A heavyweight process has a single thread of
control but a lightweight process has multiple
threads of control.
Example : A word processor may have a thread for
displaying graphics, another thread for
responding key strokes from the user and a third
thread for performing spelling and grammar
checking in the back ground.
Single and Multithreaded Processes
Operating System Concepts
Benefits
Operating System Concepts
 Responsiveness
 Resource Sharing
 Economy
 Utilization of MP Architectures
User Threads
Operating System Concepts
 Thread management done by user-level threads
library
 A user thread is normally created by a threading
library and scheduling is managed by the
threading library itself (Which runs in user mode).
All user threads belong to process that created
them.
 The advantage of user threads is that they are
portable.
 Examples
- POSIX Pthreads
- Mach C-threads
Kernel Threads
Operating System Concepts
 Supported by the Kernel
 A kernel thread is created and scheduled by the
kernel. Kernel threads are often more expensive
to create than user threads and the system calls
to directly create kernel threads are very platform
specific.
 Examples
- Windows 95/98/NT/2000
- Solaris
- Tru64 UNIX
- BeOS
- Linux
Multithreading Models
Operating System Concepts
 Many-to-One
 One-to-One
 Many-to-Many
Many-to-One
Operating System Concepts
 Many user-level threads mapped to single kernel
thread.
 Thread management is done by the thread library
in user space.
 It is efficient
 Multiple threads are unable to run in parallel on
multiprocessor because only one thread can
access the kernel at a time.
 Used on systems that do not support kernel
threads.
Many-to-One Model
Operating System Concepts
One-to-One
Operating System Concepts
 Each user-level thread maps to kernel thread.
 It provides more concurrency than many-to-one
model
 The drawback of this model is to create a kernel
thread for each user thread . This is a overhead.
 Examples
- Windows 95/98/NT/2000
- OS/2
One-to-one Model
Operating System Concepts
Many-to-Many Model
Operating System Concepts
 Allows many user level threads to be mapped to
many kernel threads.
 Allows the operating system to create a sufficient
number of kernel threads.
 Solaris 2
 Windows NT/2000 with the ThreadFiber package
Many-to-Many Model
Operating System Concepts
Threading Issues
Operating System Concepts
 Semantics of fork() and exec() system calls.
Create a new thread or duplicate the process
with all thread.
 Thread cancellation
Asynchronous or Deferred
 Signal handling
Synchronous and Asynchronous signal may be
handled by default signal handler or user-
defined signal handler.
 Thread pools
A thread pool limits the number of threads that
exist at one point.
 Thread specific data
Though the all the thread share the data ,
however in some circumstance each thread
might need its own copy of certain data. We call
such data thread specific data.
Process or CPU Scheduling
Operating System Concepts
 Maximum CPU utilization obtained with
multiprogramming
 CPU–I/O Burst Cycle – Process execution
consists of a cycle of CPU execution and I/O wait.
 CPU burst distribution
Alternating Sequence of CPU And I/O Bursts
Operating System Concepts
Histogram of CPU-burst Times
Operating System Concepts
CPU Scheduler
Operating System Concepts
 Selects from among the processes in memory
that are ready to execute, and allocates the CPU
to one of them.
 CPU scheduling decisions may take place when a
process:
1. Switches from running to waiting state.
2. Switches from running to ready state.
3. Switches from waiting to ready.
4. Terminates.
 Scheduling under 1 and 4 is nonpreemptive.
 All other scheduling is preemptive.
Criteria for Judge Best Algorithm
Operating System Concepts
 CPU utilization – keep the CPU as busy as
possible
 Throughput – The number of processes that
complete their execution per time unit
 Turnaround time – amount of time to
execute a particular process
 Waiting time – amount of time a process has
been waiting in the ready queue
 Response time – amount of time it takes
from when a request was submitted until the
first response is produced, not output (for
time-sharing environment)
Optimization Criteria
Operating System Concepts
 Max CPU utilization
 Max throughput
 Min turnaround time
 Min waiting time
 Min response time
First-Come, First-Served (FCFS) Scheduling
Operating System Concepts
Process Burst Time
P1 24
P2 3
P3 3
 Suppose that the processes arrive in the order: P1 ,
P2 , P3
The Gantt Chart for the schedule is:
 Waiting time for P1 = 0; P2 = 24; P3 = 27
 Average waiting time: (0 + 24 + 27)/3 = 17
 Implemented by FIFO queue.
P1 P2 P3
24 27 30
0
FCFS Scheduling (Cont.)
Operating System Concepts
Suppose that the processes arrive in the order
P2 , P3 , P1 .
 The Gantt chart for the schedule is:
 Waiting time for P1 = 6; P2 = 0; P3 = 3
 Average waiting time: (6 + 0 + 3)/3 = 3
 Much better than previous case.
 Convoy effect short process behind long
process
 This is a nonpreemptive algorithm.
P1
P3
P2
6
3 30
0
Shortest-Job-First (SJF)
Scheduling
Operating System Concepts
 Associate with each process the length of its next
CPU burst. Use these lengths to schedule the
process with the shortest time.
 Two schemes:
 nonpreemptive – once CPU given to the process it cannot be
preempted until completes its CPU burst.
 preemptive – if a new process arrives with CPU burst length less than
remaining time of current executing process, preempt. This scheme
is know as the
Shortest-Remaining-Time-First (SRTF).
 SJF is optimal – gives minimum average waiting time for a given set of
processes.
Example of Non-Preemptive SJF
Operating System Concepts
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
 SJF (non-preemptive)
 Average waiting time = (0 + 6 + 3 + 7)/4 = 4
P1 P3 P2
7
3 16
0
P4
8 12
Example of Preemptive SJF
Operating System Concepts
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
 SJF (preemptive)
 Average waiting time = (9 + 1 + 0 +2)/4 = 3
P1 P3
P2
4
2 11
0
P4
5 7
P2 P1
16
Example of Preemptive SJF
Operating System Concepts
Determining Length of Next CPU
Burst
Operating System Concepts
 Can only estimate the length.
 Can be done by using the length of previous CPU
bursts, using exponential averaging.
:
Define
4.
1
0
,
3.
burst
CPU
next
the
for
value
predicted
2.
burst
CPU
of
lenght
actual
1.







 1
n
th
n n
t
  .
1
1 n
n
n t 


 



Prediction of the Length of the Next CPU Burst
Operating System Concepts
Examples of Exponential
Averaging
Operating System Concepts
  =0
 n+1 = n
 Recent history does not count.
  =1
 n+1 = tn
 Only the actual last CPU burst counts.
 If we expand the formula, we get:
n+1 =  tn+(1 - )  tn-1 + …
+(1 -  )j  tn-j + …
+(1 -  )n+1 0
 Since both  and (1 - ) are less than or equal
to 1, each successive term has less weight than
its predecessor.
Priority Scheduling
Operating System Concepts
 A priority number (integer) is associated with
each process
 The CPU is allocated to the process with the
highest priority (smallest integer  highest
priority).
 Preemptive
 Non-preemptive
 SJF is a priority scheduling where priority is the
predicted next CPU burst time.
 Problem  Starvation – low priority processes
may never execute.
 Solution  Aging – as time progresses increase
the priority of the process.
 Rumor has it that, when he shut down the IBM
7094 at MIT in 1973, he found a low-priority
process that had been submitted in 1967 and
had not yet been run.
Priority Scheduling
Operating System Concepts
Round Robin (RR)
Operating System Concepts
 It is designed for time sharing system. It is similar
to FCFS but preemption is added.
 A small unit of time, called time quantum is
defined.
 The ready queue is treated as circular queue.
 The scheduler goes around the ready queue,
allocating the CPU to each process for a 1 time
quantum.
 After this time has elapsed, the process is
preempted and added to the end of the ready
queue.
 Performance
 q large  FIFO
 q small  q must be large with respect to context switch, otherwise
Example of RR with Time Quantum =
20
Operating System Concepts
Process Burst Time
P1 53
P2 17
P3 68
P4 24
 The Gantt chart is:
 Typically, higher average turnaround than SJF, but
better response.
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
0 20 37 57 77 97 117 121 134 154 162
Time Quantum and Context Switch Time
Operating System Concepts
Multilevel Queue
Operating System Concepts
 Ready queue is partitioned into separate queues:
foreground (interactive)
background (batch)
 Each queue has its own scheduling algorithm,
foreground – RR
background – FCFS
 Scheduling must be done between the queues.
 Fixed priority preemptive scheduling; (i.e., serve all from foreground
then from background). Possibility of starvation.
 Time slice – each queue gets a certain amount of CPU time which it
can schedule amongst its processes;
Multilevel Queue Scheduling
Operating System Concepts
Multilevel Feedback Queue
Operating System Concepts
 A process can move between the various queues;
aging can be implemented this way.
 Multilevel-feedback-queue scheduler defined by
the following parameters:
 number of queues
 scheduling algorithms for each queue
 method used to determine when to upgrade a process
 method used to determine when to demote a process
 method used to determine which queue a process will enter when
that process needs service
Example of Multilevel Feedback
Queue
Operating System Concepts
 Three queues:
 Q0 – time quantum 8 milliseconds
 Q1 – time quantum 16 milliseconds
 Q2 – FCFS
 Scheduling
 A new job enters queue Q0 . When it gains CPU, job receives 8
milliseconds. If it does not finish in 8 milliseconds, job is moved to
queue Q1.
 At Q1 job is again served and receives 16 additional milliseconds. If
it still does not complete, it is preempted and moved to queue Q2.
Multilevel Feedback Queues
Operating System Concepts

More Related Content

PPT
UNIT I Process management main concept.ppt
vaibavmugesh
 
PPT
LEC_3.ppt jef,fdds,fn,befhj efbhjfrgeukevbhwj
lipof22824
 
PPTX
3. Process Concept in operating system.pptx
viceprincipalbfc
 
PDF
Lecture 3_Processes in Operating Systems.pdf
jamesLau66
 
PPTX
Handling Large Data Volumes in Salesforce with Apex
MuhammadMahad31
 
PPT
Process Management.ppt
JeelBhanderi4
 
PDF
Ch3 processes
Ankit Dubey
 
PPT
OS UNIT2.ppt
DHANABALSUBRAMANIAN
 
UNIT I Process management main concept.ppt
vaibavmugesh
 
LEC_3.ppt jef,fdds,fn,befhj efbhjfrgeukevbhwj
lipof22824
 
3. Process Concept in operating system.pptx
viceprincipalbfc
 
Lecture 3_Processes in Operating Systems.pdf
jamesLau66
 
Handling Large Data Volumes in Salesforce with Apex
MuhammadMahad31
 
Process Management.ppt
JeelBhanderi4
 
Ch3 processes
Ankit Dubey
 
OS UNIT2.ppt
DHANABALSUBRAMANIAN
 

Similar to Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt (20)

PPTX
3 processes
ari9_dutta
 
PPT
Ch03- PROCESSES.ppt
MeghaSharma474761
 
PPT
Ch3
rupalidhir
 
PPT
Galvin-operating System(Ch4)
dsuyal1
 
PPT
Chapter 3 - Processes
Wayne Jones Jnr
 
PPT
Ch2_Processes_and_process_management_1.ppt
Mohammad Almuiet
 
PPT
Ch03 processes
Nazir Ahmed
 
PDF
Operating System
Hitesh Mohapatra
 
PPTX
2Chapter Two- Process Management(2) (1).pptx
jamsibro140
 
PPT
Process
Sachin MK
 
PPT
Ch4 OS
C.U
 
PPT
OSCh4
Joe Christensen
 
PDF
Processes
Mustafa Ugur Oduncu
 
PDF
Ch3OperSys
Dwight Sabio
 
PDF
OperatingSystemChp3
Dwight Sabio
 
PPT
CSW355-OS-ch3-Selected (11111111111).ppt
RashaOrban2
 
PPT
operating system for computer engineering ch3.ppt
gezaegebre1
 
3 processes
ari9_dutta
 
Ch03- PROCESSES.ppt
MeghaSharma474761
 
Galvin-operating System(Ch4)
dsuyal1
 
Chapter 3 - Processes
Wayne Jones Jnr
 
Ch2_Processes_and_process_management_1.ppt
Mohammad Almuiet
 
Ch03 processes
Nazir Ahmed
 
Operating System
Hitesh Mohapatra
 
2Chapter Two- Process Management(2) (1).pptx
jamsibro140
 
Process
Sachin MK
 
Ch4 OS
C.U
 
Ch3OperSys
Dwight Sabio
 
OperatingSystemChp3
Dwight Sabio
 
CSW355-OS-ch3-Selected (11111111111).ppt
RashaOrban2
 
operating system for computer engineering ch3.ppt
gezaegebre1
 
Ad

More from KAnurag2 (20)

PPTX
twitter ppt .pptx
KAnurag2
 
PDF
Module III - 1 - Orders of Growth.p df
KAnurag2
 
PPT
Module-2Deadlock.ppt
KAnurag2
 
PPTX
dsppt-141121224848-conversion-gate01.pptx
KAnurag2
 
PPTX
Feasibility Study.pptx
KAnurag2
 
PPT
Law-Of-Supply-_-Elasticity-of-Supply-PPT.ppt
KAnurag2
 
PPTX
dsa project.pptx
KAnurag2
 
PPTX
Transformer.pptx
KAnurag2
 
PPTX
key (1).pptx
KAnurag2
 
PPTX
C PROJECT 1.pptx
KAnurag2
 
PPTX
PPT - Independent and Dependent.pptx
KAnurag2
 
PPTX
MATH PROJECT (3).pptx
KAnurag2
 
PPT
Operting system
KAnurag2
 
PPTX
DBMS .pptx
KAnurag2
 
PPTX
ML PROJECT FINAL[1].pptx
KAnurag2
 
PPTX
Project 1.pptx
KAnurag2
 
PPTX
RELATIONSHIP IN DBMS.pptx
KAnurag2
 
PPTX
RLC Circuits^Jpedulum.pptx
KAnurag2
 
PPTX
Human-Rights_Basic-Concepts-1.pptx
KAnurag2
 
PPTX
DBMS[1].pptx
KAnurag2
 
twitter ppt .pptx
KAnurag2
 
Module III - 1 - Orders of Growth.p df
KAnurag2
 
Module-2Deadlock.ppt
KAnurag2
 
dsppt-141121224848-conversion-gate01.pptx
KAnurag2
 
Feasibility Study.pptx
KAnurag2
 
Law-Of-Supply-_-Elasticity-of-Supply-PPT.ppt
KAnurag2
 
dsa project.pptx
KAnurag2
 
Transformer.pptx
KAnurag2
 
key (1).pptx
KAnurag2
 
C PROJECT 1.pptx
KAnurag2
 
PPT - Independent and Dependent.pptx
KAnurag2
 
MATH PROJECT (3).pptx
KAnurag2
 
Operting system
KAnurag2
 
DBMS .pptx
KAnurag2
 
ML PROJECT FINAL[1].pptx
KAnurag2
 
Project 1.pptx
KAnurag2
 
RELATIONSHIP IN DBMS.pptx
KAnurag2
 
RLC Circuits^Jpedulum.pptx
KAnurag2
 
Human-Rights_Basic-Concepts-1.pptx
KAnurag2
 
DBMS[1].pptx
KAnurag2
 
Ad

Recently uploaded (20)

PPTX
Presentation saif 8.pptx Flowers bloom though storms may stay, They find thei...
gemarking678
 
PPTX
PPT Lapkas helminthiasiiiiiiiiiiiiis.pptx
ratnaernawati4
 
PPTX
网上可查学历澳大利亚国家戏剧艺术学院毕业证学历证书在线购买|NIDAOffer
1cz3lou8
 
PPTX
Induction_Orientation_PPT.pptx for new joiners
baliyannisha12345
 
PPTX
FSS seminar-cours-work the future of material surfaces.pptx
sanjaychief112
 
PPTX
Python-vs-Core-Java-A-Comparative-Deep-Dive.pptx.pptx
sachinkesharwani503
 
PDF
Fortinet LAN Edge Architect FCSS_LED_AR-7.6 Certification Study Guide.pdf
sabrina pinto
 
PPTX
beforjkkkvbjkklkccghjjjkjjjjjje after.pptx
JayeshTaneja4
 
PDF
Fortinet FCSS_LED_AR-7.6 Certification: Study Hacks With Exam Questions
sabrina pinto
 
PDF
Left Holding the Bag sequence 2 Storyboard by Mark G
MarkGalez
 
PPTX
Quattro Resourcing - Recruitment that works for you
neilsimon919
 
PPTX
How To Write A ResumeCV - Resume Writing Tips
yeasinArafath6
 
PDF
Mankiw Principles of Microeconomics 2016
NeilJohnTomandao
 
PPT
Gas turbine mark VIe control Monitoring IO.ppt
aliyu4ahmad
 
PDF
【2nd】Explanatory material of DTU(230207).pdf
kewalsinghpuriya
 
PDF
Upgrade Your Career with HR Management Training in Chandigarh – Wavy Informatics
Wavy Informatics
 
PDF
A Guide To Why Doing Nothing Is Powerful
Lokesh Agrawal
 
PPTX
Green White Modern Clean Running Presentation.pptx
Johnjuru
 
PPTX
Title The Power of Oral Communication (2).pptx
amankumar7762044
 
PPT
HUUHAA.ppt NHVGDGVBXCDGFBVGCCDJBVGDGHHVXHGVCXX
ssuser0b1c0e
 
Presentation saif 8.pptx Flowers bloom though storms may stay, They find thei...
gemarking678
 
PPT Lapkas helminthiasiiiiiiiiiiiiis.pptx
ratnaernawati4
 
网上可查学历澳大利亚国家戏剧艺术学院毕业证学历证书在线购买|NIDAOffer
1cz3lou8
 
Induction_Orientation_PPT.pptx for new joiners
baliyannisha12345
 
FSS seminar-cours-work the future of material surfaces.pptx
sanjaychief112
 
Python-vs-Core-Java-A-Comparative-Deep-Dive.pptx.pptx
sachinkesharwani503
 
Fortinet LAN Edge Architect FCSS_LED_AR-7.6 Certification Study Guide.pdf
sabrina pinto
 
beforjkkkvbjkklkccghjjjkjjjjjje after.pptx
JayeshTaneja4
 
Fortinet FCSS_LED_AR-7.6 Certification: Study Hacks With Exam Questions
sabrina pinto
 
Left Holding the Bag sequence 2 Storyboard by Mark G
MarkGalez
 
Quattro Resourcing - Recruitment that works for you
neilsimon919
 
How To Write A ResumeCV - Resume Writing Tips
yeasinArafath6
 
Mankiw Principles of Microeconomics 2016
NeilJohnTomandao
 
Gas turbine mark VIe control Monitoring IO.ppt
aliyu4ahmad
 
【2nd】Explanatory material of DTU(230207).pdf
kewalsinghpuriya
 
Upgrade Your Career with HR Management Training in Chandigarh – Wavy Informatics
Wavy Informatics
 
A Guide To Why Doing Nothing Is Powerful
Lokesh Agrawal
 
Green White Modern Clean Running Presentation.pptx
Johnjuru
 
Title The Power of Oral Communication (2).pptx
amankumar7762044
 
HUUHAA.ppt NHVGDGVBXCDGFBVGCCDJBVGDGHHVXHGVCXX
ssuser0b1c0e
 

Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt

  • 1. Processes Management Operating System Concepts  Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server Systems
  • 2. Process Concept Operating System Concepts  An operating system executes a variety of programs:  Batch system – jobs  Time-shared systems – user programs or tasks  Textbook uses the terms job and process almost interchangeably.  Process – a program in execution; process execution must progress in sequential fashion.  A process includes:  program counter  stack  data section
  • 4. Process State Operating System Concepts  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.
  • 5. Diagram of Process State Operating System Concepts
  • 6. Process Control Block (PCB) Operating System Concepts Information associated with each process.  Process state  Program counter  CPU registers  CPU scheduling information  Memory-management information  Accounting information  I/O status information
  • 7. Process Control Block (PCB) Operating System Concepts
  • 8. Context Switching Operating System Concepts  Switching the CPU to another process requires a state save of the current process and a state restore of a different process. This task is known as context switching.  The Context of a process is saved in PCB.  Context Switching time is pure overhead.  Its speed varies from machine to machine depending upon memory speed and the number of register.
  • 9. CPU Switch From Process to Process Operating System Concepts
  • 10. Process Scheduling Queues Operating System Concepts  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.  All the queues are implemented by linked list.  Each queue has a header contains pointers to the first and final PCBs.  In turn each PCB includes a pointer field that points to the next PCB  Process migration between the various queues.
  • 11. Ready Queue And Various I/O Device Queues Operating System Concepts
  • 13. Schedulers Operating System Concepts  Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue.  Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU.
  • 14. Schedulers (Cont.) Operating System Concepts  Short-term scheduler is invoked very frequently (milliseconds)  (must be fast).  Long-term scheduler is invoked very infrequently (seconds, minutes)  (may be slow).  The long-term scheduler controls the degree of multiprogramming.  Processes can be described as either:  I/O-bound process – spends more time doing I/O than computations, many short CPU bursts.  CPU-bound process – spends more time doing computations; few very long CPU bursts.
  • 15. Addition of Medium Term Scheduling Operating System Concepts
  • 16. Process Creation Operating System Concepts  Parent process create 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.  Parent and child share no resources.  Execution  Parent and children execute concurrently.  Parent waits until children terminate.
  • 17. Process Creation (Cont.) Operating System Concepts  Address space  Child duplicate of parent.  Child has a program loaded into it.  UNIX examples  fork system call creates new process  exec system call used after a fork to replace the process’ memory space with a new program.
  • 19. Process Termination Operating System Concepts  Process executes last statement and asks the operating system to delete it (exit).  Output data from child to parent (via wait).  Process’ resources are deallocated by operating system.  Parent may terminate execution of children processes (abort).  Child has exceeded allocated resources.  Task assigned to child is no longer required.  Parent is exiting.  Operating system does not allow child to continue if its parent terminates.  Cascading termination.
  • 20. Interprocess Communication (IPC) Operating System Concepts Cooperating Processes:  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
  • 21. Producer-Consumer Problem Shared-Memory System Operating System Concepts  Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process.  unbounded-buffer places no practical limit on the size of the buffer.  bounded-buffer assumes that there is a fixed buffer size.
  • 22. Bounded-Buffer – Shared-Memory Solution Operating System Concepts  Shared data #define BUFFER_SIZE 10 Typedef struct { . . . } item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; in points to the next free position out points to the first full position In==out (buffer is empty) ((in +1)%BUFFER_SIZE))==out(buffer full)  Solution is correct, but can only use BUFFER_SIZE-1 elements
  • 23. Bounded-Buffer – Producer Process Operating System Concepts item nextProduced; while (1) { while (((in + 1) % BUFFER_SIZE) == out) ; /* do nothing */ buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; }
  • 24. Bounded-Buffer – Consumer Process Operating System Concepts item nextConsumed; while (1) { while (in == out) ; /* do nothing */ nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; }
  • 25. Message Passing Systems Operating System Concepts  Mechanism for processes to communicate and to synchronize their actions without sharing memory.  Message system – processes communicate with each other without resorting to shared variables.  IPC facility provides two operations:  send(message) – message size fixed or variable  receive(message)  If P and Q wish to communicate, they need to:  establish a communication link between them  exchange messages via send/receive  Implementation of communication link  physical (e.g., shared memory, hardware bus)  logical (e.g., logical properties)
  • 26. Implementation Questions Operating System Concepts  How are links established?  Can a link be associated with more than two processes?  How many links can there be between every pair of communicating processes?  What is the capacity of a link?  Is the size of a message that the link can accommodate fixed or variable?  Is a link unidirectional or bi-directional?
  • 27. Direct Communication Operating System Concepts  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.
  • 28. Indirect Communication Operating System Concepts  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.
  • 29. Indirect Communication Operating System Concepts  Operations  create a new mailbox  send and receive messages through mailbox  destroy a mailbox  Primitives are defined as: send(A, message) – send a message to mailbox A receive(A, message) – receive a message from mailbox A
  • 30. Indirect Communication Operating System Concepts  Mailbox sharing  P1, P2, and P3 share mailbox A.  P1, sends; P2 and P3 receive.  Who gets the message?  Solutions  Allow a link to be associated with at most two processes.  Allow only one process at a time to execute a receive operation.  Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was.
  • 31. Synchronization Operating System Concepts  Message passing may be either blocking or non- blocking.  Blocking is considered synchronous  Non-blocking is considered asynchronous  send and receive primitives may be either blocking or non-blocking.
  • 32. Buffering Operating System Concepts  Queue of messages attached to the link; implemented in one of three ways. 1. Zero capacity – 0 messages Sender must wait for receiver (rendezvous). 2. Bounded capacity – finite length of n messages Sender must wait if link full. 3. Unbounded capacity – infinite length Sender never waits.
  • 33. Threads Operating System Concepts  A thread is a basic unit of CPU utilization; it comprises a thread ID, a register set, and a stack.  The thread shares its code section , data section, and other resources with other threads belongs to the same process.  A heavyweight process has a single thread of control but a lightweight process has multiple threads of control. Example : A word processor may have a thread for displaying graphics, another thread for responding key strokes from the user and a third thread for performing spelling and grammar checking in the back ground.
  • 34. Single and Multithreaded Processes Operating System Concepts
  • 35. Benefits Operating System Concepts  Responsiveness  Resource Sharing  Economy  Utilization of MP Architectures
  • 36. User Threads Operating System Concepts  Thread management done by user-level threads library  A user thread is normally created by a threading library and scheduling is managed by the threading library itself (Which runs in user mode). All user threads belong to process that created them.  The advantage of user threads is that they are portable.  Examples - POSIX Pthreads - Mach C-threads
  • 37. Kernel Threads Operating System Concepts  Supported by the Kernel  A kernel thread is created and scheduled by the kernel. Kernel threads are often more expensive to create than user threads and the system calls to directly create kernel threads are very platform specific.  Examples - Windows 95/98/NT/2000 - Solaris - Tru64 UNIX - BeOS - Linux
  • 38. Multithreading Models Operating System Concepts  Many-to-One  One-to-One  Many-to-Many
  • 39. Many-to-One Operating System Concepts  Many user-level threads mapped to single kernel thread.  Thread management is done by the thread library in user space.  It is efficient  Multiple threads are unable to run in parallel on multiprocessor because only one thread can access the kernel at a time.  Used on systems that do not support kernel threads.
  • 41. One-to-One Operating System Concepts  Each user-level thread maps to kernel thread.  It provides more concurrency than many-to-one model  The drawback of this model is to create a kernel thread for each user thread . This is a overhead.  Examples - Windows 95/98/NT/2000 - OS/2
  • 43. Many-to-Many Model Operating System Concepts  Allows many user level threads to be mapped to many kernel threads.  Allows the operating system to create a sufficient number of kernel threads.  Solaris 2  Windows NT/2000 with the ThreadFiber package
  • 45. Threading Issues Operating System Concepts  Semantics of fork() and exec() system calls. Create a new thread or duplicate the process with all thread.  Thread cancellation Asynchronous or Deferred  Signal handling Synchronous and Asynchronous signal may be handled by default signal handler or user- defined signal handler.  Thread pools A thread pool limits the number of threads that exist at one point.  Thread specific data Though the all the thread share the data , however in some circumstance each thread might need its own copy of certain data. We call such data thread specific data.
  • 46. Process or CPU Scheduling Operating System Concepts  Maximum CPU utilization obtained with multiprogramming  CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait.  CPU burst distribution
  • 47. Alternating Sequence of CPU And I/O Bursts Operating System Concepts
  • 48. Histogram of CPU-burst Times Operating System Concepts
  • 49. CPU Scheduler Operating System Concepts  Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them.  CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state. 2. Switches from running to ready state. 3. Switches from waiting to ready. 4. Terminates.  Scheduling under 1 and 4 is nonpreemptive.  All other scheduling is preemptive.
  • 50. Criteria for Judge Best Algorithm Operating System Concepts  CPU utilization – keep the CPU as busy as possible  Throughput – The number of processes that complete their execution per time unit  Turnaround time – amount of time to execute a particular process  Waiting time – amount of time a process has been waiting in the ready queue  Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
  • 51. Optimization Criteria Operating System Concepts  Max CPU utilization  Max throughput  Min turnaround time  Min waiting time  Min response time
  • 52. First-Come, First-Served (FCFS) Scheduling Operating System Concepts Process Burst Time P1 24 P2 3 P3 3  Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is:  Waiting time for P1 = 0; P2 = 24; P3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17  Implemented by FIFO queue. P1 P2 P3 24 27 30 0
  • 53. FCFS Scheduling (Cont.) Operating System Concepts Suppose that the processes arrive in the order P2 , P3 , P1 .  The Gantt chart for the schedule is:  Waiting time for P1 = 6; P2 = 0; P3 = 3  Average waiting time: (6 + 0 + 3)/3 = 3  Much better than previous case.  Convoy effect short process behind long process  This is a nonpreemptive algorithm. P1 P3 P2 6 3 30 0
  • 54. Shortest-Job-First (SJF) Scheduling Operating System Concepts  Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time.  Two schemes:  nonpreemptive – once CPU given to the process it cannot be preempted until completes its CPU burst.  preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF).  SJF is optimal – gives minimum average waiting time for a given set of processes.
  • 55. Example of Non-Preemptive SJF Operating System Concepts Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4  SJF (non-preemptive)  Average waiting time = (0 + 6 + 3 + 7)/4 = 4 P1 P3 P2 7 3 16 0 P4 8 12
  • 56. Example of Preemptive SJF Operating System Concepts Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4  SJF (preemptive)  Average waiting time = (9 + 1 + 0 +2)/4 = 3 P1 P3 P2 4 2 11 0 P4 5 7 P2 P1 16
  • 57. Example of Preemptive SJF Operating System Concepts
  • 58. Determining Length of Next CPU Burst Operating System Concepts  Can only estimate the length.  Can be done by using the length of previous CPU bursts, using exponential averaging. : Define 4. 1 0 , 3. burst CPU next the for value predicted 2. burst CPU of lenght actual 1.         1 n th n n t   . 1 1 n n n t        
  • 59. Prediction of the Length of the Next CPU Burst Operating System Concepts
  • 60. Examples of Exponential Averaging Operating System Concepts   =0  n+1 = n  Recent history does not count.   =1  n+1 = tn  Only the actual last CPU burst counts.  If we expand the formula, we get: n+1 =  tn+(1 - )  tn-1 + … +(1 -  )j  tn-j + … +(1 -  )n+1 0  Since both  and (1 - ) are less than or equal to 1, each successive term has less weight than its predecessor.
  • 61. Priority Scheduling Operating System Concepts  A priority number (integer) is associated with each process  The CPU is allocated to the process with the highest priority (smallest integer  highest priority).  Preemptive  Non-preemptive  SJF is a priority scheduling where priority is the predicted next CPU burst time.  Problem  Starvation – low priority processes may never execute.  Solution  Aging – as time progresses increase the priority of the process.  Rumor has it that, when he shut down the IBM 7094 at MIT in 1973, he found a low-priority process that had been submitted in 1967 and had not yet been run.
  • 63. Round Robin (RR) Operating System Concepts  It is designed for time sharing system. It is similar to FCFS but preemption is added.  A small unit of time, called time quantum is defined.  The ready queue is treated as circular queue.  The scheduler goes around the ready queue, allocating the CPU to each process for a 1 time quantum.  After this time has elapsed, the process is preempted and added to the end of the ready queue.  Performance  q large  FIFO  q small  q must be large with respect to context switch, otherwise
  • 64. Example of RR with Time Quantum = 20 Operating System Concepts Process Burst Time P1 53 P2 17 P3 68 P4 24  The Gantt chart is:  Typically, higher average turnaround than SJF, but better response. P1 P2 P3 P4 P1 P3 P4 P1 P3 P3 0 20 37 57 77 97 117 121 134 154 162
  • 65. Time Quantum and Context Switch Time Operating System Concepts
  • 66. Multilevel Queue Operating System Concepts  Ready queue is partitioned into separate queues: foreground (interactive) background (batch)  Each queue has its own scheduling algorithm, foreground – RR background – FCFS  Scheduling must be done between the queues.  Fixed priority preemptive scheduling; (i.e., serve all from foreground then from background). Possibility of starvation.  Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes;
  • 68. Multilevel Feedback Queue Operating System Concepts  A process can move between the various queues; aging can be implemented this way.  Multilevel-feedback-queue scheduler defined by the following parameters:  number of queues  scheduling algorithms for each queue  method used to determine when to upgrade a process  method used to determine when to demote a process  method used to determine which queue a process will enter when that process needs service
  • 69. Example of Multilevel Feedback Queue Operating System Concepts  Three queues:  Q0 – time quantum 8 milliseconds  Q1 – time quantum 16 milliseconds  Q2 – FCFS  Scheduling  A new job enters queue Q0 . When it gains CPU, job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is moved to queue Q1.  At Q1 job is again served and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q2.