SSMMPPLL SSiimmuullaattiioonn SSuubbssyysstteemm ---- UUsseerr GGuuiiddee Teemu Kerola University of Helsinki Helsinki, Finland 23.9.1988 _A_B_S_T_R_A_C_T 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. October 3, 19<9M5ACHINE>: src/smpl/guide - 2 - /********************************************************************** /* /* 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 /* /*********************************************************************/ October 3, 19<9M5ACHINE>: src/smpl/guide - 3 - _U_S_E_R _I_N_T_E_R_F_A_C_E _1_. _C_r_e_a_t_e _D_a_t_a _S_t_r_u_c_t_u_r_e_s /*************************************************************************/ /* 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; _2_. _O_u_t_p_u_t _R_o_u_t_i_n_e_s /*************************************************************************/ /* 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; October 3, 19<9M5ACHINE>: src/smpl/guide - 4 - _3_. _N_o_r_m_a_l _S_i_m_u_l_a_t_i_o_n _R_o_u_t_i_n_e_s /*************************************************************************/ /* 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; October 3, 19<9M5ACHINE>: src/smpl/guide - 5 - /*************************************************************************/ /* 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() _4_. _R_a_n_d_o_m _N_u_m_b_e_r_s October 3, 19<9M5ACHINE>: src/smpl/guide - 6 - /*************************************************************************/ /* 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; October 3, 19<9M5ACHINE>: src/smpl/guide - 7 - _5_. _O_t_h_e_r _R_o_u_t_i_n_e_s /*************************************************************************/ /* 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; October 3, 19<9M5ACHINE>: src/smpl/guide