CS457 - System Performance Evaluation - Winter 2008
Questions and Comments
- Due time for A2.
Lecture 18 - Simulation Architectures
Model Example. Routing for automated telephone support
- single server, two classes of request
- goal is something like weighted waiting time
Think of the goal like an economist
e.g., flight booking service open to individuals and travel agents
- Suppose time spent serving travel agents is twice as productive
- queueing models have a scheduling algorithm, such as
- FCFS
- priority-based FCFS
- round robin, aka take turns
- each has a natural structure
- FCFS: single queue
- priority-based: multiple queues
- round-robin: multiple queues
- with multiple classes
- arrival rate adds: r = r1 + r2
- interarrival time adds reciprocals: t = 1/r = 1/(r1 + r2 ) =
1/(1/t1 + 1/t2) = t1*t2 / (t1 + t2)
or 1/t = 1/t1 + 1/t2
- Parameters
- interarrival time: per class
- length of transaction: per class
- service capacity: per class
- queueing algorithm
- Performance metrics
- waiting time: per class
This is used to determine the cycle time of the advertising you
listen to. Just joking!
- utilization
No point in hiring any more support staff than you need.
For a more CS-like example see this pdf.
Structure of Software for Discrete Event Simulation
Two possible approaches
- Follow a request (job) through the system
- Global time with OS-like scheduling
- Local time with
sleep( )
- Event-scheduling approach
Event Scheduling
- Events
- occurrences that will change the state of a system
- happen at a specific time
- Event set - queue of events, which means
- ordered
- pointer to next event after now
- simulation time kept in a clock variable
updated to event time each time a new event occurs
Two important operations
- Remove the earliest event from now.
- Insert an event.
These will be done equally often (Why?)
- Two key assumptions
- Events are defined so that the system never changes state without
an event occurring.
- Events can schedule other events, but never in the past.
This is called causality.
- Defining system state is the most important aspect of abstraction.
Event Scheduling Program
* marks parts that do not vary from program to program
Highest Level Description
Initialize( ); //*
while ( ( event = GetNextEvent( event-set ) ) != nil ) { //*
clock.time = event.time; //*
process-event( event ); //*
}
log.output( ); //*
Initialization
clock.init( ); //*
state.init( ); //*
event-set.init( ); //*
log.init( ); //*
Event Processing
log.update( event ); //*
event-set.insert( new-event( ) ) //*
// Possibly test for termination
state.update( event ); //*
Server with One Queue
Response variables
Factors
- Interarrival times
- Service times
Assumptions
- Some things are independent of everything else
- interarrival times
- service times
- FCFS scheduling
- System starts empty
- Infinite population (open model)
State variuables
- n - number of jobs in the queue
- status - server busy or idle
Initialization
clock.init( ) { time = 0 } //*
state.init( ) { n = 0; status = IDLE }
log.init( ) { /* open output channel */ }
event-state.init( ) { queue.insert( new-event( ) ) }
Arrival event
log.update( event ) { /* whatever */ }
state.update( event ) { n++; queue.insert( event ); if( status == IDLE ) start_service( ) }
Departure event
log.update( event ) { /* whatever */ }
state.update( event ) { status = IDLE; if( --n ) { start_service( ) }
Utility routines
event new-event( ) { incr = SCALE * random( ); event.time = clock + incr, event.type = ARRIVAL }
start-service( ) {
state.status = BUSY;
Return to: