CS457 - System Performance Evaluation - Winter 2010


Public Service Announcements

  1. Assignment 1 office hours
  2. Assignment 2.

Lecture 16 - Discrete Event Simulation

Simulation

What is it?

Examples

Models

Model taxonomy

Common Model Contrasts
Continuous Discrete
Determinism Fully deterministic: possible
if input is a trace
Details modelled probabilistically
Start with the same seed to get determinism
State
Continuous
e.g. know that processing is
x% complete, which is necessary
for round robin scheduling
Discrete: change system state
only when things start of end
(events)
Time Make time steps
as small as possible.
Time moves forward discontinuously,
from event to event

Model development

  1. You did this before
  2. Select the type of queueing model
  3. Specify attributes that need algorithms
  4. Specify workload parameters and performance metrics
  5. You should now be able to specify

Example. Routing for automated telephone support

For a more CS-like example see this pdf.


Structure of Software for Discrete Event Simulation

Two possible approaches

  1. Follow a request (job) through the system
  2. Event-scheduling approach

Event Scheduling

  1. Events
  2. Event set - queue of events, which means

    Two important operations

    1. Remove the earliest event from now.
    2. Insert an event.

    These will be done equally often (Why?)

  3. Two key assumptions
    1. Events are defined so that the system never changes state without an event occurring.
    2. Events can schedule other events, but never in the past.
      This is called causality.
  4. 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 = event-set.dequeue( ) ) ) != nil ) { //*
    clock.time = event.time; //*
    process-event( event ); //*
}
log.terminate( ); //*

Initialization

Initialize( ){
    clock.init( ); //*
    state.init( ); //*
    event-set.init( ); //*
    log.init( ); //*
}

Event Processing

process-event( event ){
    log.update( /* Whatever */ ); //*
    state.update( event ); //*
    // Possibly test for termination
}

Server with One Queue

Response variables

Parameters = Factors

Assumptions

  1. Some things are independent of everything else
  2. FCFS scheduling
  3. System starts empty
  4. Infinite population (open model)

State variuables

Initialization

clock.init( ) { time = 0 } //*
state.init( ) { n = 0; status = IDLE }
log.init( ) { /* open standard output */ }
event-state.init( ) { event-set.insert( new-event( ARRIVAL, clock.time( ) ) ) }

State & Event-set Manipulation

state.update( event ) {
    switch( event.type ) {
    case ARRIVAL:
        event-set.insert( new-event( ARRIVAL, event.time ) );
        n++; queue.insert( event );
        if( status == IDLE ) start_service( );
        return;
    case DEPARTURE:
        status = IDLE;
        if ( --n ) start_service( );
        return;
    }
}

Utility routines

event new-event( type, time ) {
    this.type = type;
    switch( type ) {
    case ARRIVAL:
        this.time = time + event.arrival-time( );
        return this;
    case DEPARTURE:
        this.time = time + event.service-time( );
        return this;
    }
}

start-service( event ) {
    log.update( /* Whatever */ );
    job = queue.next( );
    state.status = BUSY;
    event-set.insert( new-event( DEPARTURE, event.time ) ) 
}

Left as exercises for the reader

  1. Trace through the samples and make certain that it all goes as you expect.
  2. Find out the slightly different termination condition than the example in the notes.
  3. Think about what should go in all the updates of the log.

Important.


Return to: