home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 349_01 / sss.arc / EX_0805.FOR < prev    next >
Text File  |  1991-04-15  |  3KB  |  113 lines

  1. C     Program EX_0805.FOR
  2. C     Listing 17F - see documentation in TUTOR.SSS
  3.  
  4. $include:'SSSF1.H'
  5.  
  6.       subroutine prime
  7. $include:'SSSF2.H'
  8.       integer TIMEL, REPTME
  9.       character*5 a0
  10.       integer*1 i(5)
  11.       common TIMEL, REPTME, a0
  12.       equivalence (a0, i)
  13.       i(1) = 27
  14.       i(2) = 91
  15.       i(3) = 55
  16.       i(4) = 57
  17.       i(5) = 68
  18.       TIMEL = 120
  19.       REPTME = -1
  20.       call INIQUE(1, 1, 1)
  21.       call INISTA(1,'bus                   ',1,0,0,0)
  22.       call TALLY(1, 1)
  23.       call CREATE(0, 0)
  24.       call CREATE(TIMEL, REPTME)
  25.       return
  26.       end
  27.  
  28.       subroutine signal
  29. $include:'SSSF2.H'
  30.       integer TIMEL, REPTME
  31.       character*5 a0
  32.       common TIMEL, REPTME, a0
  33.       write(*,'(A,F6.2,A\)')'Simulated time ',T(),a0
  34.       return
  35.       end
  36.  
  37.       Program EX_0805
  38. $include:'SSSF2.H'
  39.       integer TIMEL, REPTME
  40.       character*5 a0
  41.       common TIMEL, REPTME, a0
  42.       integer ARRIVL, STARTA, ENDACT, NEXTAC, REPORT,
  43.      +  SSIZE, n, server, ecode, countr
  44.       data  ARRIVL/1/, STARTA/2/, ENDACT/3/, NEXTAC/4/
  45.       data  REPORT/5/, SSIZE/4/
  46.       data  n/0/, server/1/, countr/0/
  47.  
  48.       call prime
  49.  
  50.    99 ecode = NEXTEV()
  51.       if (ecode.gt.0) then
  52.         goto (101, 102, 103, 104, 105) ecode
  53.  
  54. C ARRIVL
  55.   101   continue
  56.         if (IDE().eq.REPTME) then
  57.           call SCHED(0, REPORT, IDE())
  58.         else
  59.           n = n + 1
  60.           call signal
  61.           call SETA(1, EX(0.9))
  62.           call CREATE(EX(1), n)
  63.           call SCHED(0, NEXTAC, IDE())
  64.         endif
  65.         goto 99
  66.  
  67. C NEXTAC
  68.   104   continue
  69.         if (server.gt.0) then
  70.           call SCHED(0.0, STARTA, IDE())
  71.         else
  72.           call QUEUE(1, 0.0)
  73.         endif
  74.         goto 99
  75.  
  76. C STARTA
  77.   102   continue
  78.         call SCHED(A(1), ENDACT, IDE())
  79.         server = server - 1
  80.         call TALLY(1, server)
  81.         goto 99
  82.  
  83. C REPORT
  84.   105   continue
  85.         call SCHED(TIMEL, REPORT, IDE())
  86.         if (countr.eq.0) then
  87.            write(*,'(A)')' # average avail.s         '
  88.          else
  89.            write(*,'(A,I1,F8.1,F8.3,A)')' ',countr,
  90.      +       QAVG(1),SAVG(1),'                '
  91.          endif
  92.          call CLEARQ(1)
  93.          call CLEARS(0)
  94.          countr = countr + 1
  95.          if (countr.gt.SSIZE) call SIMEND(0)
  96.         goto 99
  97.  
  98. C ENDACT
  99.   103   continue
  100.         call DISPOS
  101.         server = server + 1
  102.         call TALLY(1, server)
  103.         if (NQ(1).gt.0) then
  104.           call REMVFQ(1, 1)
  105.           call SCHED(0.0, STARTA, IDE())
  106.         endif
  107.         goto 99
  108.  
  109.       else
  110.         stop 'End of simulation'
  111.       endif
  112.       end
  113.