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

  1. ' Program EX_0805.BAS
  2. ' Listing 17B - see documentation in TUTOR.SSS
  3.  
  4. const ARRIVL = 1, STARTA = 2, ENDACT = 3, NEXTAC = 4
  5. const REPORT = 5, TIMEL = 120, REPTME = -1, SSIZE = 4
  6.  
  7. common shared n, countr, server, ecode, a1$, b$
  8.  
  9. declare sub prime ()
  10.  
  11. rem $include: 'SSSB.H'
  12.  
  13.   call prime
  14.  
  15.   do
  16.     ecode = NEXTEV
  17.     if ecode > 0 then
  18.       select case ecode
  19.  
  20.       case ARRIVL
  21.              if IDE = REPTME then
  22.                SCHED 0, REPORT, IDE
  23.              else
  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.              end if
  31.  
  32.       case NEXTAC
  33.              if server > 0 then
  34.                SCHED 0, STARTA, IDE
  35.              else
  36.                QUEUE 1, 0
  37.              end if
  38.  
  39.       case STARTA
  40.              SCHED A(1), ENDACT, IDE
  41.              server = server - 1
  42.              TALLY 1, server
  43.  
  44.       case ENDACT
  45.              DISPOS
  46.              server = server + 1
  47.              TALLY 1, server
  48.              if NQ(1) > 0 then
  49.                 REMVFQ 1, 1
  50.                 SCHED 0, STARTA, IDE
  51.              end if
  52.  
  53.       case REPORT
  54.              SCHED TIMEL, REPORT, IDE
  55.              if countr = 0 then
  56.                print "# average avail.s            "
  57.              else
  58.                print using a1$; countr; QAVG(1); SAVG(1)
  59.              end if
  60.              CLEARQ 1
  61.              CLEARS 0
  62.              countr = countr + 1
  63.              if countr > SSIZE then SIMEND 0
  64.  
  65.       end select
  66.     end if
  67.   loop while ecode > 0
  68.  
  69. end
  70.  
  71. sub prime
  72.   a1$ = "# #####.# ###.###               "
  73.   b$ = "Simulated time: #####.##     "
  74.   n = 0
  75.   countr = 0
  76.   server = 1
  77.   INIQUE 1, 1, 1
  78.   title$ = "bus                  "
  79.   INISTA 1, sadd(title$), 1, 0, 0, 0
  80.   TALLY 1, server
  81.   CREATE 0, n
  82.   CREATE TIMEL, REPTME
  83. end sub
  84.