home *** CD-ROM | disk | FTP | other *** search
- ' Program EX_0604.BAS
- ' Listing 13B - see documentation in TUTOR.SSS
-
- const ARRIVL = 1, STARTA = 2, ENDACT = 3, NEXTAC = 4
- const ORDNRY = 0, DELUX = 1
-
- common shared id, server, ecode
-
- declare sub prime ()
- declare sub preemp ()
-
- rem $include: 'SSSB.H'
-
- call prime
-
- do
- ecode = NEXTEV
- if ecode > 0 then
- select case ecode
-
- case ARRIVL
- id = di + 1
- CREATE EX(2), id
- SETA 1, 0
- SETA 2, TR(1, 2, 3)
- if RA < .25 then
- SETA 3, DELUX
- else
- SETA 3, ORDNRY
- end if
- SCHED 0, NEXTAC, IDE
-
- case NEXTAC
- if server > 0 then
- SCHED 0, STARTA, IDE
- elseif A(3) = DELUX then
- preemp
- else
- QUEUE 1, 0
- end if
-
- case STARTA
- SCHED A(2), ENDACT, IDE
- server = server - 1
-
- case ENDACT
- if A(3) <> DELUX then TALLY 1, A(1)
- DISPOS
- server = server + 1
- if NQ(2) > 0 then
- REMVFQ 2, 1
- SCHED 0, STARTA, IDE
- elseif NQ(1) > 0 then
- REMVFQ 1, 1
- SCHED 0, STARTA, IDE
- end if
-
- end select
- end if
- loop while ecode > 0
-
- title$ = " "
- SUMRY sadd(title$)
-
- sub preemp
- QUEUE 2, 0
- i = 1
- found = 0
- if NC > 0 then
- for j = 1 to NC
- if AIC(j, 3) = DELUX or NEIC(j) <> ENDACT then
- if found = 0 then i = i + 1 else found = 1
- end if
- next j
- end if
-
- if i <= NC then
- remt = TIC(i) - t
- REMVFC i
- SETA 1, A(1) + 1
- SETA 2, remt
-
- title$ = "LIFO "
- SETQDC 1, sadd(title$)
- QUEUE 1, 0
- title$ = "FIFO "
- SETQDC 1, sadd(title$)
- REMVFQ 2, 1
- SCHED 0, STARTA, IDE
- end if
- end sub
-
- sub prime
- server = 2
- id = 0
- INIQUE 2, 3, 1
- title$ = "Interrupts "
- INISTA 1, sadd(title$), 0, 0, 0, 0
- SIMEND 60
- CREATE 0, 0
- end sub
-