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.BAS < prev    next >
BASIC Source File  |  1991-04-10  |  2KB  |  123 lines

  1. ' Program EX_0807.BAS
  2. ' Listing 18B - see documentation in TUTOR.SSS
  3.  
  4. const ARRIVL = 1, STARTA = 2, ENDACT = 3, NEXTAC = 4
  5. const TIMEL = 120
  6.  
  7. common shared n, countr, server, ecode, a1$, b$, t0#
  8.  
  9. declare sub prime ()
  10. declare sub resque ()
  11. declare sub endper ()
  12.  
  13. rem $include: 'SSSB.H'
  14.  
  15.   call prime
  16.  
  17.   do
  18.     ecode = NEXTEV
  19.     if ecode > 0 then
  20.       select case ecode
  21.  
  22.       case ARRIVL
  23.              if n = countr * TIMEL then endper
  24.              n = n + 1
  25.              print using b$; T;
  26.              locate , 1
  27.              SETA 1, EX(.9)
  28.              CREATE EX(1), n
  29.              SCHED 0, NEXTAC, IDE
  30.  
  31.       case NEXTAC
  32.              if server > 0 then
  33.                SCHED 0, STARTA, IDE
  34.              else
  35.                QUEUE 1, 0
  36.              end if
  37.  
  38.       case STARTA
  39.              SCHED A(1), ENDACT, IDE
  40.              server = server - 1
  41.              TALLY 1, server
  42.  
  43.       case ENDACT
  44.              DISPOS
  45.              server = server + 1
  46.              TALLY 1, server
  47.              if NQ(1) > 0 then
  48.                 REMVFQ 1, 1
  49.                 SCHED 0, STARTA, IDE
  50.              end if
  51.  
  52.       end select
  53.     end if
  54.   loop while ecode > 0
  55.  
  56. end
  57.  
  58. sub endper
  59.   select case countr
  60.   case 0
  61.     SETSEE 777
  62.     SETANT 0
  63.  
  64.   case 1
  65.     print "# average avail.s duration    "
  66.  
  67.   case 2
  68.     print using a1$; countr; QAVG(1); SAVG(1); T - t0#
  69.  
  70.   case 3
  71.     print using a1$; countr; QAVG(1); SAVG(1); T - t0#
  72.     QUEUE 2, 0
  73.     resque
  74.     server = 1
  75.     REMVFQ 2, 1
  76.     SETSEE 777
  77.     SETANT 1
  78.  
  79.   case 4
  80.  
  81.   case 5
  82.     print using a1$; countr; QAVG(1); SAVG(1); T - t0#
  83.  
  84.   case 6
  85.     print using a1$; countr; QAVG(1); SAVG(1); T - t0#
  86.     SIMEND 0
  87.  
  88.   end select
  89.  
  90.   CLEARS 0
  91.   CLEARQ 1
  92.   countr = countr + 1
  93.   t0# = T
  94. end sub
  95.  
  96. sub prime
  97.   a1$ = "# #####.# ###.### #####.##      "
  98.   b$ = "Simulated time: #####.##     "
  99.   n = 0
  100.   countr = 0
  101.   server = 1
  102.   t0# = 0
  103.   INIQUE 2, 1, 1
  104.   title$ = "bus                  "
  105.   INISTA 1, sadd(title$), 1, 0, 0, 0
  106.   TALLY 1, server
  107.   CREATE 0, n
  108. end sub
  109.  
  110. sub resque
  111.   CLEARS 0
  112.   CLEARQ 0
  113.   while NQ(1) > 0
  114.     REMVFQ 1, 1
  115.     DISPOS
  116.   wend
  117.   while NC > 0
  118.     REMVFC 1
  119.     DISPOS
  120.   wend
  121. end sub
  122.  
  123.