CSIM19 tutorial - PowerPoint PPT Presentation

About This Presentation
Title:

CSIM19 tutorial

Description:

CSIM19 tutorial Reference: http://www.mesquite.com/ Introduction CSIM19 A library of routines Process-oriented, discrete-event simulation package for use with C or ... – PowerPoint PPT presentation

Number of Views:97
Avg rating:3.0/5.0
Slides: 35
Provided by: cml54
Category:

less

Transcript and Presenter's Notes

Title: CSIM19 tutorial


1
CSIM19 tutorial
  • Reference http//www.mesquite.com/

2
Introduction
  • CSIM19
  • A library of routines
  • Process-oriented, discrete-event simulation
    package for use with C or C programs
  • A CSIM program
  • It models a system as a collection of CSIM
    processes which interact with each other

3
Introduction
  • CSIM provides the following simulation objects
  • CSIM processes processes
  • CSIM objects facilities, storages, buffers,
    events, mailboxes
  • Statistics tables, qtables, meters,

4
Simulation time
  • CSIM maintains a simulation clock, with value
    equals to current time in the model
  • Different from the CPU time used or the real
    world time
  • Starts at zero
  • A double precision floating point

5
Simulation time
  • Retrieving the current time
  • 1. Simtime function
  • Prototype double simtime (void)
  • Example x simtime ()
  • 2. Reference the variable clock
  • Example x clock
  • Delaying for an amount of time
  • Prototype void hold (double amount_of_time)
  • Example hold (1.0)

6
Process
  • It is the active entities in a model
  • It is a procedure which executes the create
    statement
  • A process must be in four states
  • Active computing
  • Ready to begin computing
  • Holding
  • Waiting for an event

7
Initiating a process
  • Prototype void proc (arg1, , argn)
  • Example my_proc (a, 64, proc)
  • Note
  • A create statement must appear in the initiated
    process
  • A process cannot return a function value

8
Creating a process
  • Prototype void create (char name)
  • Example create (customer)
  • Note
  • Executes at the beginning of a process
  • Process can initiate other processes
  • No simulation time passes

9
Process operation
  • Processes appear to operate simultaneously at the
    point in simulation time
  • Processes execute until they suspend themselves
    by
  • Execute a hold statement
  • The process is put into a queue
  • Execute a csim_terminate statement

10
Terminating a process
  • A process terminates when
  • A normal procedure exit, or
  • Executes a terminate statement
  • Prototype void csim_terminate (void)
  • Example csim_terminate ()

11
Changing the process priority
  • Initial priority of a process is inherited from
    the initiator of that process
  • Default priority is 1
  • Prototype void set_priority (long new_priority)
  • Example set_priority (5)
  • Note
  • Must appear after the create statement
  • Lower values represent lower priorities

12
Reporting process status
  • Print the status of each active process
  • Prototype void status_processes (void)
  • Example status_processes ()

13
Facilities
  • It models a resource in a simulated system
  • Processes are ordered in a facility queue by
    their priorities.
  • A higher priority process is ahead of a lower
    priority process.

14
Declaring and initiating a facility
  • Declaring
  • Dynamic example facility fd
  • Initiating
  • Prototype facilityfacility (char name)
  • Dynamic example fd new facility (fac)
  • Static example facility fs (fac)
  • Note
  • The facility name is only used only to identify
    the facility in output reports and trace messages

15
Using a facility
  • A process can use a facility for a specified
    interval of time.
  • If the facility is free, then the process gains
    exclusive use of the server until the end of the
    usage interval
  • If the facility is busy, then the process is put
    in a queue of waiting processes.
  • Prototype void facilityuse (double
    service_time)
  • Example fd-gtuse(1.0)

16
Reserving and releasing a facility
  • In case a process acquires a server other than
    entering the usage interval
  • Reserve to gain exclusive use of a server
  • Release to relinquish use of the server
  • Prototype void facilityreserve (void)
  • void facilityrelease (void)
  • Dynamic example
  • fd-gtreserve () fd-gtrelease ()

17
Reserving and releasing a facility
  • Note
  • When a process executes a reserve, it either
  • 1) gets use of the server, or
  • 2) it is suspended and placed in a waiting queue
  • The process releasing a server must be the same
    process reserved it. Otherwise, use
    release_server ()
  • fd-gtreserve (f) hold (t) fd-gtrelease (f)
  • fd-gtuse (t)
  • fd-gtreserve (f) hold (exponential(t))
    fd-gtrelease (f)
  • ! fd-gtuse (exponential(t))

18
Producing reports
  • Prototype void facility_report (void)
  • Example facility_report ()

19
Releasing a specific server at a facility
  • Used when one process reserves a facility and
    then for another process to release
  • Prototype void facilityrelease_server (long
    server_index)
  • Dynamic example server_index fd-gtreserve ()
  • fd-gtrelease_server (server_index)
  • Note
  • The first process has to save the index of the
    server and gives it to the second process
  • This is the same as release except the ownership
    is not checked

20
Declaring and initializing a multi-server facility
  • Prototype facility_msfacility_ms (char name,
    long number_of_servers)
  • Dynamic example cpud new facility_ms (cpus,
    2)
  • Static example facility_ms cpus (cpus, 2)
  • Note
  • A process gains access to any free server when
    reserve()

21
Facility sets
  • Prototype facility_setfacility_set (char
    name, long num_of_facilities)
  • Dynamic example facility_set diskd diskd new
    facility_set (disk, 10)
  • Static example
  • facility_set disks (disk, 10)
  • disksi.use (exponential(1.0))

22
Events
  • Used to synchronize the operations of CSIM
    processes
  • An event can only be in occurred or not occurred
    state

23
Declaring and initializing an event
  • Prototype eventevent (char name)
  • Dynamic example event ed ed new event
    (done)
  • Static example event es (done)

24
Waiting for an event
  • Waiting for an event
  • Prototype void eventwait (void)
  • Dynamic example e-gtwait ()
  • Waiting with a time-out
  • Prototype long eventtimed_wait (double tout)
  • Dynamic example res ed-gttimed_wait (100.0) if
    (res ! TIMED_OUT)

25
Queuing for an event
  • Prototype void eventqueue (void)
  • Dynamic example ed-gtqueue ()
  • Note
  • This behaves like wait function, except that at
    each time event is set only one queued process is
    resumed.

26
Setting an event
  • Prototype void eventset (void)
  • Dynamic example ed-gtset ()
  • Note
  • It causes all waiting processes and one queue
    process to be resumed
  • If there is no waiting event, the event will be
    in occurred state upon return from set function

27
Clearing an event
  • Prototype void eventclear (void)
  • Dynamic example ed-gtclear ()
  • Note
  • Clearing an event that is in not occurred state
    has no effect

28
Event sets
  • Prototype event_setevent_set (char name, long
    number_of_events)
  • Dynamic example event_set ed_set
  • ed_set new event_set (events, 10)
  • Static example
  • event_set es_set (events, 10)
  • es_set3.set ()

29
Producing Report
  • Status report
  • Prototype void status_events (void)
  • Dynamic example status_events ()

30
Tables
  • To gather statistics on a sequence of discrete
    values such as interarrival times, service times,
  • It does not actually store the recorded values,
    it just simply updates the statistics
  • The statistics maintained include min, max,
    range, mean, var, std dev, coef of var
  • Can add histogram, calculation of confidence
    intervals

31
Declaring and initializing a table
  • Prototype tabletable (char name)
  • Dynamic example table td
  • td new table (response time)
  • Static example table ts (response time)

32
Tabulating values
  • Prototype void tablerecord (double value)
  • Dynamic example td-gtrecord (1.0)
  • Note
  • Tables are designed to maintain statistics on
    data type of type double only

33
Producing reports
  • Prototype void tablereport (void)
  • Dynamic example td-gtreport ()
  • Note
  • report_tables () to produce reports for all
    tables

34
Histograms and confidence intervals
  • Histograms
  • Prototype void tableadd_histogram (long
    nbucket, double min, double max)
  • Static example ts.add_histogram (10, 0.0, 10.0)
  • Confidence intervals
  • Prototype void tableconfidence (void)
  • Static example ts.confidence ()
Write a Comment
User Comments (0)
About PowerShow.com