SMPL Simulation Subsystem - User Guide Teemu Kerola University of Helsinki Helsinki, Finland 23.9.1988 SMPL is a collection of routines that can be used to implement discrete event simulators. Users need to write their own main program, where all the facilities in the system and actions for all the events are defined. This version of SMPL is written in C. Original SMPL was written in PL/I by M.H. MacDougall for Amdahl Corporation in April 1980. /********************************************************************** /* /* smpl simulation subsystem /* /* pl/1 implementation - m.h. macdougall, april 1980 /* converted to mnf - ted gruber, march 1981 /* converted to VMS - herb schwetman, june 1981 /* converted to C - teemu kerola, july 1981 /* /* use: compile file containing simulation routine "sim()" /* with "smpl.o -lm". /* source file must include "#include smpl.h". /* /* e.g.: cc -o ModelXX ModelXX.c smpl.o -lm /* /* Execute model file ModelXX with command line /* ModelXX i1 i2 i3 i4 .. i9 /* input values (int) /* /* command line options: /* -------------------- /* -trace /* -tr trace info for each event. /* /* -test i /* -t i TEST option; high value much test output. /* /* -smpltest i /* -s i STEST (Smpl TEST) option; -"- . /* /* -dump i /* -d i DUMP option; high value more dumps. /* e.g. 1 -> dump in case of smpl errors /* 2 -> dump at the end of simulation /* 10 -> dump at each event /* 1000 -> dump at each trans. allocation /* /*********************************************************************/ USER INTERFACE Create Data Structures /*************************************************************************/ /* smpl - initialize simulation subsystem called mdl /*************************************************************************/ smpl (mdl) char mdl[]; /* name of model */ /*************************************************************************/ /* facility - define facility named name with n servers. /* return facility number f. /*************************************************************************/ int facility (name, n) char *name; int n; Output Routines /*************************************************************************/ /* report - user interface to reporter /*************************************************************************/ report() /*************************************************************************/ /* check - print complete data dump /*************************************************************************/ check() /*************************************************************************/ /****/ /* trace - turn trace tr to flag /* trace value is also set by -tr command line option /*************************************************************************/ trace (flag) int flag; Normal Simulation Routines /*************************************************************************/ /* reset - reset facility and queue statistics /*************************************************************************/ reset (flag) int flag; /*************************************************************************/ /* schedule - schedule event e at token tkn to happen after time t /*************************************************************************/ schedule (e, t, tkn) int e, tkn; float t; /*************************************************************************/ /* cause - cause next event to happen. return event e and token tkn /*************************************************************************/ cause (e, tkn) int *e, *tkn; /*************************************************************************/ /* reserve - reserve facility f for token tkn with priority pri /* return 0 if reserved, 1 if queued /*************************************************************************/ int reserve (f, tkn, pri) int f, tkn; float pri; /*************************************************************************/ /* preempt - preempt facility f by token tkn with priority pri /* return: 0 - ok, 1 - queued. /*************************************************************************/ int preempt (f, tkn, pri) int f, tkn; float pri; /*************************************************************************/ /* release - release token tkn from facility f /*************************************************************************/ release(f, tkn) int f, tkn; /*************************************************************************/ /* qlength - return queue length at facility f /*************************************************************************/ int qlength (f) int f; /*************************************************************************/ /* id - return server reserved for token tkn at facility f /*************************************************************************/ int id (f, tkn) int f, tkn; /*************************************************************************/ /* status - return facility status for device f: /* 0 = free, 1 = busy. /*************************************************************************/ int status (f) int f; /*************************************************************************/ /* time - return current simulation time /*************************************************************************/ float ftTime() /*************************************************************************/ /* cputime - return current cputime /*************************************************************************/ float cputime() Random Numbers /*************************************************************************/ /* expntl - return random from Exp (x1) /*************************************************************************/ float expntl (x1) float x1; /*************************************************************************/ /* prob - return random from Uniform [0, 1) /*************************************************************************/ float prob() /*************************************************************************/ /* random - return integer random from Equiprob (i1, i2) /*************************************************************************/ int random (i1, i2) int i1, i2; /*************************************************************************/ /* uniform - return random from Uniform [x1, x2) /*************************************************************************/ float uniform (x1, x2) float x1, x2; Other Routines /*************************************************************************/ /* testoption - user return testoption /*************************************************************************/ int testoption () /*************************************************************************/ /* cmdinput - return i:th additional (integer) input value /* given as command line parameter i+2 (i=1,2,...,9) /*************************************************************************/ int cmdinput (i) int i; /*************************************************************************/ /* checkcmd - check for the command as an input argument /*************************************************************************/ checkcmd(cmd) int cmd;