home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!haven.umd.edu!decuac!pa.dec.com!ninja!zowie.zso.dec.com!ridder
- From: ridder@zowie.zso.dec.com (Hans)
- Subject: Re: RKM description of WaitPort()
- Message-ID: <1993Jan5.193827.23221@ninja.zso.dec.com>
- Sender: news@ninja.zso.dec.com (USENET News System)
- Nntp-Posting-Host: zowie.zso.dec.com
- Organization: Digital Equipment Corporation - DECwest Engineering
- References: <1993Jan1.221013.26070@urbana.mcd.mot.com> <1ib7peINNele@uwm.edu>
- Date: Tue, 5 Jan 1993 19:38:27 GMT
- Lines: 50
-
- In article <1ib7peINNele@uwm.edu> bloc1469@ee.ee.uwm.edu (Gregory R Block) writes:
- >In article <1993Jan1.221013.26070@urbana.mcd.mot.com> qbarnes@urbana.mcd.mot.com (Quentin Barnes) writes:
- >>It seems to me to OS is waking up the task before it has attached the
- >>message to the specified port and it would be up the the application
- >>to spin on the GetMsg() call until the message generating the signal
- >>showed up.
- >
- >No, it's just possible to send a signal to a port without sending a
- >message.
-
- There is a much more likely cause of a signal bit being set without
- there being a message. It probably occurs *very* frequently which is
- the reason programs break quite quickly if message processing isn't done
- correctly. The sequence of events goes like this (pay attention now
- ;-):
-
- Your task calls Wait() with the signal bit for a message port. A
- message (such as an IntuiMsg) arrives at your message port causing the
- signal bit to be set, thus waking your task. The Wait() returns after
- clearing the signal bit. Your task enters the usual loop calling
- GetMsg() until NULL is returned. While your task is processing
- messages, a higher priority task (like the input.device task) or an
- interrupt preempts your message processing loop and winds up placing
- another message on your port, setting your signal bit again. Your task
- is resumed, and you continue processing *all* the messages, including
- the one which just caused your signal bit to be set.
-
- Note that emptying a message port does *not* clear the corresponding
- signal bit (since other ports may be sharing the same signal bit.) Now
- with the message port empty your task calls Wait() again, which
- immediatly returns due to the signal bit being set. There are however,
- no messages to be processed....
-
- Therefore, you *must* be sure to check the return from GetMsg() for
- NULL, *even if* you just returned from a Wait() indicating a message has
- arrived.
-
- In any case, the wording in the Autodocs is at best completly
- misleading, and more likely just plain wrong. I can't imagine any
- circumstance where the signal bit will be set, but the message has not
- arrived on the port *yet*. I welcome any discussion to the contrary.
-
- >Greg
-
- -hans
- --
- Hans-Gabriel Ridder <ridder@rust.zso.dec.com>
- DECwest Engineering, Bellevue, Washington, USA
- "I'd rather be writing MACRO-20!"
- Any opinions expressed are not those of my employer, honest.
-