1 / 34

CSIM19 tutorial

CSIM19 tutorial. Reference: http://www.mesquite.com/. 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.

nakia
Download Presentation

CSIM19 tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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: facility::facility (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 facility::use (double service_time); • Example: fd->use(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 facility::reserve (void); void facility::release (void); • Dynamic example: • fd->reserve (); fd->release ();

  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->reserve (f); hold (t); fd->release (f);” = fd->use (t); • “fd->reserve (f); hold (exponential(t)); fd->release (f);” =!= fd->use (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 facility::release_server (long server_index); • Dynamic example: server_index = fd->reserve (); • fd->release_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_ms::facility_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_set::facility_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); disks[i].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: event::event (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 event::wait (void); • Dynamic example: e->wait (); • Waiting with a time-out • Prototype: long event::timed_wait (double tout); • Dynamic example: res = ed->timed_wait (100.0); if (res != TIMED_OUT) …

  25. Queuing for an event • Prototype: void event::queue (void); • Dynamic example: ed->queue (); • 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 event::set (void); • Dynamic example: ed->set (); • 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 event::clear (void); • Dynamic example: ed->clear (); • Note: • Clearing an event that is in not occurred state has no effect

  28. Event sets • Prototype: event_set::event_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_set[3].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: table::table (char *name); • Dynamic example: table *td; • td = new table (“response time”); • Static example: table ts (“response time”);

  32. Tabulating values • Prototype: void table::record (double value); • Dynamic example: td->record (1.0); • Note: • Tables are designed to maintain statistics on data type of type double only

  33. Producing reports • Prototype: void table::report (void); • Dynamic example: td->report (); • Note: • report_tables () to produce reports for all tables

  34. Histograms and confidence intervals • Histograms: • Prototype: void table::add_histogram (long nbucket, double min, double max); • Static example: ts.add_histogram (10, 0.0, 10.0); • Confidence intervals: • Prototype: void table::confidence (void); • Static example: ts.confidence ();

More Related