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 >
Wrap
Text File
|
1991-04-16
|
4KB
|
166 lines
C Program EX_0807.FOR
C Listing 18F - see documentation in TUTOR.SSS
$include:'SSSF1.H'
subroutine prime
$include:'SSSF2.H'
real*8 t0
character*5 a0
integer*1 i(5)
integer countr, server
common a0, t0, countr, server
equivalence (a0, i)
countr = 0
server = 1
n = 0
i(1) = 27
i(2) = 91
i(3) = 55
i(4) = 57
i(5) = 68
call INIQUE(2, 1, 1)
call INISTA(1,'bus ',1,0,0,0)
call TALLY(1, 1)
call CREATE(0, 0)
return
end
subroutine signal
$include:'SSSF2.H'
real*8 t0
character*5 a0
integer countr, server
common a0, t0, countr, server
write(*,'(A,F6.2,A\)')' Simulated time ',T(),a0
return
end
subroutine resque
$include:'SSSF2.H'
call CLEARS(0)
call CLEARQ(0)
11 continue
if (NQ(1).gt.0) then
call REMVFQ(1, 1)
call DISPOS
goto 11
endif
21 continue
if (NC().gt.0) then
call REMVFC(1)
call DISPOS
goto 21
endif
return
end
subroutine endper
$include:'SSSF2.H'
real*8 t0
character*5 a0
integer countr, server
common a0, t0, countr, server
990 format(A,I1,F8.1,F8.3,F9.2,A)
i = countr + 1
goto (1,2,3,4,5,6,7) i
1 call SETSEE(777)
call SETANT(0)
goto 999
2 write(*,'(A)')' # average avail.s duration '
goto 999
3 write(*,990) ' ', countr, QAVG(1), SAVG(1),
+ T()-t0, ' '
goto 999
4 write(*,990) ' ', countr, QAVG(1), SAVG(1),
+ T()-t0, ' '
call QUEUE(2, 0)
call resque
server = 1
call REMVFQ(2, 1)
call SETSEE(777)
call SETANT(1)
goto 999
5 goto 999
6 write(*,990) ' ', countr, QAVG(1), SAVG(1),
+ T()-t0, ' '
goto 999
7 write(*,990) ' ', countr, QAVG(1), SAVG(1),
+ T()-t0, ' '
call SIMEND(0)
return
999 call CLEARS(0)
call CLEARQ(1)
countr = countr + 1
t0 = T()
return
end
Program EX_0807
$include:'SSSF2.H'
real*8 t0
character*5 a0
integer countr, server
common a0, t0, countr, server
integer ARRIVL, STARTA, ENDACT, NEXTAC, TIMEL
+ n, ecode
data ARRIVL/1/, STARTA/2/, ENDACT/3/, NEXTAC/4/
data TIMEL/120/
data n/0/
call prime
99 ecode = NEXTEV()
if (ecode.gt.0) then
goto (101, 102, 103, 104) ecode
C ARRIVL
101 continue
if (n.eq.countr*TIMEL) call endper
n = n + 1
call signal
call SETA(1, EX(0.9))
call CREATE(EX(1), n)
call SCHED(0, NEXTAC, IDE())
goto 99
C NEXTAC
104 continue
if (server.gt.0) then
call SCHED(0.0, STARTA, IDE())
else
call QUEUE(1, 0.0)
endif
goto 99
C STARTA
102 continue
call SCHED(A(1), ENDACT, IDE())
server = server - 1
call TALLY(1, server)
goto 99
C ENDACT
103 continue
call DISPOS
server = server + 1
call TALLY(1, server)
if (NQ(1).gt.0) then
call REMVFQ(1, 1)
call SCHED(0.0, STARTA, IDE())
endif
goto 99
else
stop 'End of simulation'
endif
end