Source files: src/MemSys/driver.c, src/MemSys/act.c, src/MemSys/pool.c, src/MemSys/userq.c, src/MemSys/util.c
Header files: incl/MemSys/simsys.h
All actions that take place during the course of an RSIM simulation occur as part of YACSIM events. Each event has a function for its body, an argument for use on invocation, and a state used for subsequent invocations of the same event. Each time an event is scheduled, the body function is invoked. The event is not deactivated until the body function returns control to the simulator (through a return statement or the end of the function). Thus, an event can be thought of as a function call scheduled to occur at a specific point in simulated time, possibly using a previously-set argument and state value and/or setting a state value and argument for use on a future invocation.
An event is a specific type of YACSIM Activity; however, it is the only type used in RSIM. The following functions are used for manipulating events in RSIM.
This function constructs a new event and returns its pointer. The state of the event is initialized to 0. The ename argument specifies the name of the event. bodyname is a pointer to a function that will be invoked on each activation of the event. The function must take no arguments and must have no return value; the argument actually used by the event is passed in through ActivitySetArg described below and is read with ActivityGetArg. delflg can be either DELETE or NODELETE, and specifies whether the storage for the event can be freed at the end of its invocation. Events specified with DELETE can only be scheduled once, whereas NODELETE events can reschedule themselves or be rescheduled multiple times. The type argument is available for any use by the user of the event-driven simulation library. RSIM events always have this field set to 0.
This function can only be called within the body of an event, and it sets the state value of the event to stval.
This function returns the state value of the calling event, and can be used at the beginning of the event to determine the current state of the event.
This function sets the argument of the event pointed to by aptr to the value of argptr, with argsize the size of the argument structure in bytes. Note that the argument is passed in by pointer; consequently, the value of the argument structure at the time of event invocation may differ from the value of the argument strucutre at the time when the argument is set, if intervening operations reset the value of the structure.
This function returns the argument pointer for a given event; if this function is called with a NULL pointer or the predefined value ME, the function returns the argument pointer for the calling event.
This function returns the size of the argument structure for a given event; if this function is called with a NULL pointer or the predefined value ME, the function returns the argument size for the calling event.
This operation schedules the event pointed to be aptr for timeinc cycles in the simulated future. The only valid value of blkflg for events is INDEPENDENT.
This operation schedules the next invocation of the event for timeinc cycles in the simulated future. The state of the event upon rescheduling will be stval. (This function must be called within the event to be rescheduled, whereas ActivitySchedTime can be called from another event or from outside an event.)
This operation schedules the event pointed to be aptr for the time when the semaphore pointed to by semptr becomes available (described in Section 8.2). The only valid value of blkflg for events is INDEPENDENT.
This operation schedules the next invocation of the event according to the time when the semaphore pointed to by semptr becomes available. The state of the event upon rescheduling will be stval. (This function must be called within the event to be rescheduled, whereas ActivitySchedTime can be called from another event or from outside an event.)
The YACSIM event-list is implemented as a calendar queue [2]. Event-list processing in YACSIM is controlled by the function DriverRun(double timeinc), which processes the event list for timeinc cycles or until the event list has no more events scheduled (if the value of timeinc given is less than or equal to 0).
The function void YS__errmsg(char *s) can be used at any point in the simulation to print out the error message s and terminate the simulation. This function is commonly used for unexpected simulation occurrences. The function void YS__warnmsg(char *s) prints out the warning message s on the simulation output file, but does not terminate the simulation. This function can be used to warn of unexpected happenings in the simulated system.