Process Fundamentals, Queueing Theory, - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Process Fundamentals, Queueing Theory,

Description:

P(exit)=limn(n/30)/( (n/30) (n/5) ) = 1/7. P(time slice)=limn(n/5)/( (n/30) (n/5) ) = 6/7 ... next event: (0, 89, Exit) Update Statistics. Schedule queued job ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 35
Provided by: siue
Category:

less

Transcript and Presenter's Notes

Title: Process Fundamentals, Queueing Theory,


1
Process Fundamentals, Queueing Theory,
Simulation
  • Stephen Blythe

2
Process States
  • A process state describes its current status
  • running
  • waiting
  • for I/O to complete
  • for an available CPU
  • for system call to complete
  • ... ???
  • completed
  • ... ???

3
Process State Transitions
4
Process State Transitions ...
5
Process State Transitions ...
6
Process State Transitions ...
7
Process States O/S Design
  • Any change in am O/S state means an O/S change
  • code modification
  • performance changes
  • extra hardware needed now?
  • ...
  • Can either just build the new O/S (costly) ...
  • ... or simulate the new system (cheaper), giving
  • performance measures
  • prediction of hardware needs
  • ...
  • ... or ...

8
Queuing Theory
  • ... OR , perform queuing analysis
  • formal, mathematical analysis of states and
    queues
  • under assumptions, gives accurate results
  • no need for any coding whatsoever!
  • but, one needs to understand the math involved

9
Queuing Theory ...
  • Consider the following simple queuing system
  • given that
  • the system is stable (the queue is finite)
  • ?in is job arrival rate (new jobs per sec.)
  • ?out is job completion rate (jobs finished per
    sec.)
  • Can we relate ?in to ?out ?

CPU
?in ?out (Surprise!!)
10
Queuing Theory ...
  • Other quantities of interest
  • Ts average service time (time in CPU)
  • Tw average wait time (time spent in CPU queue)
  • w average number waiting jobs (CPU queue
    length)
  • ? average server utilization (CPU utilization)
  • r average number of jobs in system
  • Tr average response time
  • Some simple observations/formulas
  • TrTsTw
  • ??inTs
  • r?inTr (Littles formula/law)

11
Queuing Theory ...
  • since TrTs/(1-?) and r?inTr ,
  • r?inTs/(1-?)
  • (?inTs)/(1-?)
  • ?/(1-?) ?
  • Can you show that w?2/(1-?) ?
  • How about Tw?Ts/(1-?) ?

12
O/S Example
?ts
?in
?out
Ts
  • What does adding a time slice do?
  • Suppose
  • ?in 1 job / 60 sec
  • Ts 20 sec/job
  • Prob(?ts) Prob(?out)

0.5
13
O/S Example ...
?ts
?in
?out
Ts
?in ?ts
  • ?out ?in
  • ?out 0.5 (?in ?ts)
  • ?ts 0.5 (?in ?ts)
  • 0.5 ?ts 0.5 ?in
  • ?ts ?in

14
O/S Example ...
?ts
?in
?out
Ts
?in ?ts
  • But, theres a catch
  • derived equations assume only 1 pass through
    CPU
  • this model has several
  • how long is typical pass through CPU?
  • Assume it is 10 seconds here (well discuss
    later)
  • now, have 2 passes through CPU with Ts10
  • and Tr 2 (10/(1-?)) 210/(1-1/3)30 (secs.)

15
O/S Example ...
?ts
?in
?out
Ts
?in ?ts
  • Another catch dont know probabilities in
    advance
  • Do know time time slice length, though!!
  • ex. Ts30s , time slice5s, ?in1job/100seconds
  • over n secs, exitsn/30, time slicesn/5 (at
    most)
  • P(exit) exits/(exits time slices)
  • P(time slice) time slices(exits time
    slices)
  • time in CPU P(event)(event length)

16
O/S Example ...
?ts
?in
?out
Ts
?in ?ts
  • P(exit)limn?8(n/30)/( (n/30)(n/5) ) 1/7
  • P(time slice)limn?8(n/5)/( (n/30)(n/5) ) 6/7
  • again Ts30s , time slice5s, ?in1job/100seconds
  • ?ts6/7(?in?ts), so ?ts6?in
  • ?(?in?ts)Ts7?inTs7(1/100)(30/7)3/10
  • Tr6 passes (Ts/(1-?)) 65/(1-3/10)300/7

17
Another Option
  • As systems get larger and more complex ...
  • ... Queuing Analysis becomes more difficult
  • ... sometimes too difficult.
  • Instead, perform a discrete event simulation
  • simulates large amounts of system time (years)
  • ... taking only seconds of real time
  • ... calculates important statistics along the
    way
  • Tr, ? (for all devices in system), ...

18
Discrete Event Simulation
  • The core of Discrete Event Simulation is the
    event
  • In O/S, an event is an action that needs O/S
    intervention
  • new job arriving
  • time slice expiring
  • job requires I/O
  • job completes
  • I/O completes
  • ...

19
Discrete Event Simulation ...
  • Basic Idea
  • start with a single seed event (process
    arrival)
  • add the event to a sorted event queue
  • set curr_time0
  • while(queue not empty curr_timeltmax_time)
  • remove first event ev from queue
  • set curr_timeev.time
  • update internal statistics
  • generate next event(s) based on this event
  • add the new events to the queue

20
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • seed event 1st process enters

Statistics curr_time 0 jobs_done 0
CPU_time 0
21
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process event (0,0, New)
  • adds (0,75, Exit) and ...

Statistics curr_time 0 jobs_done 0
CPU_time 0
22
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process event (0,0, New)
  • adds (0,75, Exit) and ...
  • (1, 100, New)

Statistics curr_time 0 jobs_done 0
CPU_time 0
23
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process event (0,75, Exit)
  • updates stats

Statistics curr_time 75 jobs_done 1
CPU_time 75
24
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process event (1,100, New)
  • adds (1, 175, Exit) and
  • (2,200, New)

Statistics curr_time 100 jobs_done 1
CPU_time 75
25
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process event (1,175, Exit)
  • updates stats

Statistics curr_time 175 jobs_done 2
CPU_time 150
26
Discrete Event Simulation ...
  • When done, will have
  • total time in CPU
  • total time so far
  • number of jobs completed
  • could also track other stats along the way
  • but there are problems
  • real jobs dont have constant CPU (or arrival)
    times
  • vary values using exponential random distribution
  • CPU queue not used in prior example

27
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • seed event 1st process enters

CPU Queue
CPU Status
idle
Statistics curr_time 0 jobs_done 0
CPU_time 0
28
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process event (0, 0, New)
  • generate CPU time 89 ns
  • generate next new 08686 ns

CPU Queue
0
CPU Status
idle
Statistics curr_time 0 jobs_done 0
CPU_time 0
29
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • check CPU - is it busy?
  • yes, so pull a job from queue
  • schedule CPU exit event

CPU Queue
CPU Status
busy
Statistics curr_time 0 jobs_done 0
CPU_time 0
30
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process next event (1, 86, New)
  • CPU busy, so add to queue
  • generate next new 86112198

CPU Queue
1
CPU Status
busy
Statistics curr_time 86 jobs_done 0
CPU_time 86
31
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process next event (0, 89, Exit)
  • Update Statistics
  • Schedule queued job (t8951)

CPU Queue
CPU Status
busy
Statistics curr_time 89 jobs_done 1
CPU_time 89
32
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process next event (1, 140, Exit)
  • Update Statistics
  • No jobs in queue ...

CPU Queue
CPU Status
idle
Statistics curr_time 140 jobs_done 2
CPU_time 140
33
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process next event (2, 198, New)
  • queue empty, run on CPU (exit event)
  • generate next new event

CPU Queue
CPU Status
busy
Statistics curr_time 198 jobs_done 2
CPU_time 140
34
Discrete Event Simulation ...
  • Example - two state model
  • jobs arrive every 100 ns
  • takes 75 ns to serve them
  • process next event (2, 276, Exit)
  • update statistics
  • queue empty ...

CPU Queue
CPU Status
busy
Statistics curr_time 276 jobs_done 3
CPU_time 218
Write a Comment
User Comments (0)
About PowerShow.com