CS457 - System Performance Evaluation - Winter 2010
Public Service Announcements
- Mid-term Examination: February 23rd, 16.30 at 18.00 in PHY145.
- Assignment 3.
Lecture 19 - A Final Simulation Example
Processor Sharing
Time-slicing model: pre-emptive multi-tasking
For example, three classes of jobs
- Jobs with active I/O: long think times, very little processing
- Interactive jobs without active I/O: substantial processing that will
stop and start at widely spaced times
- Batch jobs: which go on for very long times.
Single server, three queues, needs a scheduling algorithm (discipline)
- Typical scheduling algorithm: try to provide some service to each
- For example, round-robin scheduling
- N requests go into N queues
- When one request has used up its current atom
- put it back into its queue, and
- put in the request in the next queue.
- Abstraction
- service time for each request is a large number of atoms of
time
- number of atoms a request gets per second depends on the number
of requests being serviced
- therefore number of seconds required is
serv-time [atoms] / avail-atoms [atoms/sec] = serv-time [atoms] /
( (1/N) * unit [atoms/sec] )
Important state
- number of non-empty queues, m
- number of jobs currently in each queue, N(r),
r=1...M
Initialization
- The usual
- All queues empty
- One request (job) of each type in event-set
Arrival
- increment N(r)
- add request to queue
- if at head of queue,
- increment m
- reschedule existing departure events
- one more queue shares the processor
- scheduled departure events will occur later
- multiply time remaining (dep-time - clock) by
m/(m-1)
- What about dividing by zero?
- start-service
Departure
- remove job from queue, decrement N(r)
- if N(r) == 0
- decrement m
- reschedule existing departure events
- one less queue shares the processor
- scheduled departure events will occur earlier
- multiply time remaining (dep-time - clock) by
m/(m+1)
- What about multiplying by zero?
- else
Start-service
- work out departure time
- schedule departure event
Something is unrealistic about this model. What is it?
- no rescheduling within a queue
- A3 takes that into account
Something is unintuitive about this model. What is it?
- I have been justifying this approach in terms of implementation
simplicity and efficiency.
- But these qualities are starting to recede as things get more complex.
For example, queue-dependent importance.
This is always the case.
Random Variables
The mathematical foundation for random number is the random variable,
which is a variable that has different values on different occasions.
- A probability distribution determines what values a random variable
gets, and how often
- Discrete versus continuous random variables
- We usually assume that the random variables we want are independent and
identically distributed (iid or IID).
- Why is this assumption reasonable?
- Think about where we get the distributions from.
- Most random variables we use have underlying distributions that are
non-negative.
- Random variables are normally written as capitals.
Random variable concepts
- Cumulative distribution function (cdf or CDF):
- F(x) = P(X <=
x)
- F(0) = 0
- F(infinity) = 1
- Probability density function (pdf or PDF):
- Continuous distributions only
- F(x) = \int_0^x
f(x') dx'
- Mean: \mu = E(X) = \int_0^\infinity
x'f(x')dx'
- Variance: \sigma^2 =
E((X-E(X))^2) = \int_0^\infinity
(x'-E(X))^2
f(x')dx'
- Probability mass function (pmf or PMF):
- Discrete distributions only: x takes a value fro a countable set
{x_1, x_2, x_3, ...} where ... may or may
not terminate
- P(X = x_i) =
p_i
- \sum_i p_i = 1
- F(x) =
\sum_(x_i<=x) p_i
- Mean: E(X) = \sum_i
x_i p_i
- Variance: \sum_i (x_i -
E(X) )^2 p_i
In discrete event simulation we model quantities like interarrival time or
service time as IID random variables.
As a result we need to generate random variables from random number
generators.
- Random number generators normally produce random floating point numbers
uniformally distributed between 0 and 1. (Technically, in the range
[0.0..1.0).)
- We need to know how to transform this output into the distribution we
want.
Random variables with arbitrary distributions
A random variable is uniquely defined by its CDF, F(x).
- 0 <= F(x) <= 1
- Suppose we want to express this random variable as a transformation Y =
g(X) of a uniformly distributed random variable.
- P(Y < y) = F_y(y) = P(X < g^-1(y) ) = F_x( g^-1(y) ).
- Choose g(x) = F_x(x). Then P(Y < y) = 1/y, or f_y(y) = 1/(length of
interval). Y is uniformly distributed.
Examples of Discrete Distributions
- Bernoulli
- Discrete uniform
- Geometric Discrete
- Binomial
Poisson
Return to: