Docsity

Computer Simulation: Time Slicing vs Event Scheduling in Sequential Model Execution - Prof, Study notes of Computer Science

Toggle sidebar
bg1
CAP 4800/5805 Computer Simulation Concepts
Lecture 9
Serial Model Execution
• Two primary approaches to executing a system model on a sequential: time slicing,
event scheduling
• The key attribute of time slicing over the event scheduling method is in the way that
time is incremented: through addition
Time Slicing
• Time slicing involves incrementing time using a global clock by adding a certain
amount to the clock value over time
• A virtual clock is updated in intervals of some arbitrary size which can change
throughout the simulation
• The system is normally defined as a group of functions each of which must be
evaluated at the end of each interval.
• The time-slicing method can be inefficient in circumstances where the values of inputs
and outputs do not change regularly.
• The time-slicing method is appropriate for continuous system with continually varying
inputs, state values, and the outputs.
• Algorithm for time-slice execution
Begin Main
Initialize state variables
Loop through all functions
While not end of simulation
UpdateFunctions
End while
End Main
Procedure UpdateFuncations
For all functions
Switch on function type
Case type 1: apply function type 1 to state and inputs
pf3

Partial preview of the text

Download Computer Simulation: Time Slicing vs Event Scheduling in Sequential Model Execution - Prof and more Study notes Computer Science in PDF only on Docsity!

CAP 4800/5805 Computer Simulation Concepts

Lecture 9

Serial Model Execution

  • Two primary approaches to executing a system model on a sequential: time slicing , event scheduling
  • The key attribute of time slicing over the event scheduling method is in the way that time is incremented: through addition

Time Slicing

  • Time slicing involves incrementing time using a global clock by adding a certain amount to the clock value over time
  • A virtual clock is updated in intervals of some arbitrary size which can change throughout the simulation
  • The system is normally defined as a group of functions each of which must be evaluated at the end of each interval.
  • The time-slicing method can be inefficient in circumstances where the values of inputs and outputs do not change regularly.
  • The time-slicing method is appropriate for continuous system with continually varying inputs, state values, and the outputs.
  • Algorithm for time-slice execution Begin Main Initialize state variables Loop through all functions While not end of simulation UpdateFunctions End while End Main Procedure UpdateFuncations For all functions Switch on function type Case type 1: apply function type 1 to state and inputs

Case type 2: apply function type 2 to state and inputs … Case type n: apply function type n to state and inputs End For Increment time using time slice End UpdateFunctions

Event Scheduling

  • Event scheduling is defined as executing code that contains an event loop where events are posted and then checked according to minimum time
  • The event on the future event list with the minimum time tag executes first
  • Event scheduling can be likened to a “calendar” or an “alarm clock” in that events are scheduled to occur at a specific date or time

Example of Event Scheduling: Single-Server Queue

  • The next arrival time is always relative to the last arrival time
  • The next departure time depends on whether there is an entity already in the system besides the entity that is departing o If there is no other entity, the next departure time is relative to the next arrival time o If there is another entity, the next departure time is relative to the last departure time D 0 = 0 Di = max( Di-1 , Ai ) + σi Di refers to the departure time of the customer i , Ai is the arrivals, and σi represents the time to service customer i. Table 1 displays the example of a single-server queue and five customers. TABLE 1 Behavior of a single-server function i Ai σi Di 1 0 3 3 2 2 4 7 3 10 4 14 4 13 2 16 5 22 1 23