Article View: comp.sys.amiga.tech
Article #9703Waiting on Signals
From: Wade Bickel
Date: Tue, 06 Sep 1988 10:16
Date: Tue, 06 Sep 1988 10:16
75 lines
2751 bytes
2751 bytes
I'm trying to respond to some signals, and the code is not working
quite as I expected. In the following code I'm trying to wait for two
possible signals and then respond to them...
(* In Benchmark Modula-2 *)
PROCEDURE ProcSig(Sig : SignalSet);
BEGIN
IF CARDINAL(WIN^.UserPort^.mpSigBit) IN Sig THEN
LOOP
msg := GetMsg(WIN^.UserPort^);
IF msg = NIL THEN EXIT; END;
ProcIMsg(wp, msg);
IF AllDone THEN RETURN; END;
END; (* LOOP *)
END; (* IF *)
IF CARDINAL(UImsgPort^.mpSigBit) IN Sig THEN
LOOP
UI := GetMsg(UImsgPort^);
IF UI = NIL THEN EXIT; END;
ProcUImsg(UI);
IF AllDone THEN RETURN; END;
END;
END;
END ProcSig;
BEGIN (* MAIN *)
...
(* init code and startup checks ensure the msg port is working *)
...
(* Make a window refrenenced by WIN *)
...
AllDone := FALSE;
WHILE NOT AllDone DO
sig := Wait(SignalSet{CARDINAL(WIN^.UserPort^.mpSigBit),
CARDINAL(UImsgPort^.mpSigBit)});
ProcSig(sig);
END; (* WHILE *)
...
(* Cleanup *)
END programname.
Running the above code seems to work find except that in ProcSig()
the UImsgPort^.mpSigBit is never found to be in Sig. By removing the check
to see if a UImsg has been received (and using GetMsg(UImsgPort^) returns
NIL to check) UImsgs are indeed found on the port, and it appears that the
signal from that source is what woke up the process.
Any Ideas? I'm new to Modula-2 sets (I used to work in assembly),
am I expressing this incorrectly? Any other ideas?
Thanks in advance...
Wade.
UUCP: {cbosgd, hplabs!hp-sdd, sdcsvax, nosc}!crash!pnet01!haitex
ARPA: crash!pnet01!haitex@nosc.mil
INET: haitex@pnet01.CTS.COM
Opionions expressed are mine, and not necessarily those of my employer.
Technical Details
Message-ID:
<3402@crash.cts.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!ucsd!ucsdhub!jack!crash!pnet01!haitexShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!ucsd!ucsdhub!jack!crash!pnet01!haitex From: haitex@pnet01.cts.com (Wade Bickel) Newsgroups: comp.sys.amiga.tech Subject: Waiting on Signals Message-ID: <3402@crash.cts.com> Date: 6 Sep 88 10:16:28 GMT Sender: news@crash.cts.com Organization: People-Net [pnet01], El Cajon CA Lines: 75