home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 21
/
CD_ASCQ_21_040595.iso
/
dos
/
prg
/
pas
/
nwtp06
/
tstsema2.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-03-01
|
2KB
|
87 lines
{$X+,B-,V-}
Program tstsema2;
{ Example for the nwSema unit / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
uses nwMisc,nwConn,nwSema;
Var ConnNbr:Byte;
seqNbr:Word;
NbrOfSema:Byte;
SemaInfo:TconnSema;
SemValue:Integer;
info:TsemaInfoList;
t:byte;
s:string;
handle4,handle5,
handle6,handle7:LongInt;
openCount:word;
begin
connNbr:=2;seqNbr:=0;
OpenSemapHore('SEMA4',4,handle4,openCount);
OpenSemaphore('SEMAPHORE5',5,handle5,OpenCount);
OpenSemapHore('SEM6',6,handle6,OpenCount);
OpenSemapHore('SEMAP7',7,handle7,OpenCount);
writeln('Semaphores have been opened..');
writeln;
writeln('<RETURN> to continue..');
readln(s);
GetConnectionNumber(connNbr); { my connection number }
seqNbr:=1;
REPEAT
IF NOT GetConnectionsSemaphores(ConnNbr,seqNbr,NbrOfSema,SemaInfo)
then begin
writeln('GetConnectionsSemaphores returned error #', nwSema.result);
seqNbr:=0;
end
else begin
writeln;
writeln('NbrOfSema Left to Scan: ',NbrOfSema);
writeln('Next seq Nbr : ',seqNbr);
with SemaInfo
do begin
writeln('Sema Name:',Name);
writeln('Opencount:',OpenCount);
writeln('Value :',Value);
writeln('TaskNbr :',taskNbr);
end;
end;
UNTIL seqNbr=0;
seqNbr:=1;
REPEAT
IF GetSemaphoreInformation('SEMA4',seqNbr,
OpenCount,SemValue,NbrOfSema,info)
then begin
writeln;
writeln('Test of GetSemaphoreInformation...');
writeln('Connections using semaphore:',Opencount);
writeln('Semaphore value:',semvalue);
If NbrOfSema>100
then NbrOfSema:=100;
for t:=1 to NbrOfSema
do writeln('Record #:',t,' Connection: ',info[t].ConnNbr,' Task: ',info[t].taskNbr);
end
else writeln('GetSemaphoreInformation returned error #', nwSema.result);
UNTIL seqNbr=0;
CloseSemaphore(handle4);
CloseSemaphore(handle5);
CloseSemaPhore(handle6);
CloseSemaphore(handle7);
end.