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_0807.FOR < prev    next >
Text File  |  1991-04-16  |  4KB  |  166 lines

  1. C     Program EX_0807.FOR
  2. C     Listing 18F - see documentation in TUTOR.SSS
  3.  
  4. $include:'SSSF1.H'
  5.  
  6.       subroutine prime
  7. $include:'SSSF2.H'
  8.       real*8 t0
  9.       character*5 a0
  10.       integer*1 i(5)
  11.       integer countr, server
  12.       common a0, t0, countr, server
  13.       equivalence (a0, i)
  14.       countr = 0
  15.       server = 1
  16.       n      = 0
  17.       i(1) = 27
  18.       i(2) = 91
  19.       i(3) = 55
  20.       i(4) = 57
  21.       i(5) = 68
  22.       call INIQUE(2, 1, 1)
  23.       call INISTA(1,'bus                   ',1,0,0,0)
  24.       call TALLY(1, 1)
  25.       call CREATE(0, 0)
  26.       return
  27.       end
  28.  
  29.       subroutine signal
  30. $include:'SSSF2.H'
  31.       real*8 t0
  32.       character*5 a0
  33.       integer countr, server
  34.       common a0, t0, countr, server
  35.       write(*,'(A,F6.2,A\)')' Simulated time ',T(),a0
  36.       return
  37.       end
  38.  
  39.       subroutine resque
  40. $include:'SSSF2.H'
  41.       call CLEARS(0)
  42.       call CLEARQ(0)
  43.   11  continue
  44.       if (NQ(1).gt.0) then
  45.         call REMVFQ(1, 1)
  46.         call DISPOS
  47.         goto 11
  48.       endif
  49.   21  continue
  50.       if (NC().gt.0) then
  51.         call REMVFC(1)
  52.         call DISPOS
  53.         goto 21
  54.       endif
  55.       return
  56.       end
  57.  
  58.       subroutine endper
  59. $include:'SSSF2.H'
  60.       real*8 t0
  61.       character*5 a0
  62.       integer countr, server
  63.       common a0, t0, countr, server
  64.  990  format(A,I1,F8.1,F8.3,F9.2,A)
  65.       i = countr + 1
  66.       goto (1,2,3,4,5,6,7) i
  67.  
  68.   1   call SETSEE(777)
  69.       call SETANT(0)
  70.       goto 999
  71.  
  72.   2   write(*,'(A)')' # average avail.s duration    '
  73.       goto 999
  74.  
  75.   3   write(*,990) ' ', countr, QAVG(1), SAVG(1),
  76.      +             T()-t0, '       '
  77.       goto 999
  78.  
  79.   4   write(*,990) ' ', countr, QAVG(1), SAVG(1),
  80.      +             T()-t0, '       '
  81.       call QUEUE(2, 0)
  82.       call resque
  83.       server = 1
  84.       call REMVFQ(2, 1)
  85.       call SETSEE(777)
  86.       call SETANT(1)
  87.       goto 999
  88.  
  89.   5   goto 999
  90.  
  91.   6   write(*,990) ' ', countr, QAVG(1), SAVG(1),
  92.      +             T()-t0, '       '
  93.       goto 999
  94.  
  95.   7   write(*,990) ' ', countr, QAVG(1), SAVG(1),
  96.      +             T()-t0, '       '
  97.       call SIMEND(0)
  98.       return
  99.  
  100.  999  call CLEARS(0)
  101.       call CLEARQ(1)
  102.       countr = countr + 1
  103.       t0 = T()
  104.       return
  105.       end
  106.  
  107.       Program EX_0807
  108. $include:'SSSF2.H'
  109.       real*8 t0
  110.       character*5 a0
  111.       integer countr, server
  112.       common a0, t0, countr, server
  113.       integer ARRIVL, STARTA, ENDACT, NEXTAC, TIMEL
  114.      +  n, ecode
  115.       data  ARRIVL/1/, STARTA/2/, ENDACT/3/, NEXTAC/4/
  116.       data  TIMEL/120/
  117.       data  n/0/
  118.  
  119.       call prime
  120.  
  121.    99 ecode = NEXTEV()
  122.       if (ecode.gt.0) then
  123.         goto (101, 102, 103, 104) ecode
  124.  
  125. C ARRIVL
  126.   101   continue
  127.         if (n.eq.countr*TIMEL) call endper
  128.         n = n + 1
  129.         call signal
  130.         call SETA(1, EX(0.9))
  131.         call CREATE(EX(1), n)
  132.         call SCHED(0, NEXTAC, IDE())
  133.         goto 99
  134.  
  135. C NEXTAC
  136.   104   continue
  137.         if (server.gt.0) then
  138.           call SCHED(0.0, STARTA, IDE())
  139.         else
  140.           call QUEUE(1, 0.0)
  141.         endif
  142.         goto 99
  143.  
  144. C STARTA
  145.   102   continue
  146.         call SCHED(A(1), ENDACT, IDE())
  147.         server = server - 1
  148.         call TALLY(1, server)
  149.         goto 99
  150.  
  151. C ENDACT
  152.   103   continue
  153.         call DISPOS
  154.         server = server + 1
  155.         call TALLY(1, server)
  156.         if (NQ(1).gt.0) then
  157.           call REMVFQ(1, 1)
  158.           call SCHED(0.0, STARTA, IDE())
  159.         endif
  160.         goto 99
  161.  
  162.       else
  163.         stop 'End of simulation'
  164.       endif
  165.       end
  166.