18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

tialized to zero. If no expression list appears, all, if any, user-defined attributes are set to zero.<br />

Thus, the preamble definition:<br />

processes<br />

every SERVICE has a SERVER, a CUSTOMER,<br />

and may own a TRANSACTION.SET<br />

followed in some routine by the statement:<br />

schedule a SERVICE giving TELLER(N) and F.QUEUE at time expression<br />

assigns the values of TELLER(N) and F.QUEUE to the attributes SERVER and CUSTOMER, respectively,<br />

but leaves the set-ownership attributes set to zero. Following the conventional notation of<br />

the call statement, a number of argument list forms may be used: the word given may be used,<br />

or the argument list enclosed in parentheses. No yielded phrase may be used. Examples are:<br />

schedule an ARRIVAL giving ORIGIN now<br />

reschedule this SERVICE giving A and B in 2 days<br />

As these attributes are initialized at the time of scheduling, their values are unchanged by filing and<br />

removing them from the future event set. Thus, they provide a means for passing values to event<br />

and process routines. There are some difficulties, however, attached to accessing these values within<br />

the routines. Upon entry to an event routine, the associated event notice is usually destroyed, and<br />

so the attributes are no longer accessible. This is not the case for process notices. A process has a<br />

lifetime associated with the duration of an activity, whereas an event is instantaneous. Process notices<br />

are not automatically destroyed until completion of all activity represented by the process. The<br />

automatic destruction of an event notice is suppressed by appending the phrase saving the<br />

event notice to the event routine definition, as in:<br />

event ARRIVAL saving the event notice<br />

In this way, the attributes can be accessed within the event routine, or even later. The global variable<br />

with the name of the event is set by the timing routine to the event notice pointer before execution<br />

of the event routine is initiated, and so may be used to subscript the attributes. The event<br />

notice may be later destroyed as for any temporary entity. Care should be taken not to alter the value<br />

of this variable, by schedule statements, for example, until all attributes have been accessed, or<br />

before using it in destroying the event notice. It must not, of course, be redefined as a local variable,<br />

as this makes access to the global value impossible. In the case of processes, a system-maintained<br />

global variable, process.v, holds at all times either a pointer to the process notice of the currently<br />

executing process, or a zero value if no process routine is executing. Thus, this variable may be<br />

used within a process routine or within subprograms called from a process routine, to access the attributes<br />

of the associated process notice. Such a subprogram can test process.v to determine<br />

whether, in this instance, it has been called from a process or a nonprocess routine.<br />

A second way in which the values of attributes passed to an event or a process routine may be made<br />

available is to define a list of given arguments to the routine. At entry to the routine, and in the case<br />

198

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!