Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!sunybcs!bingvaxu!leah!itsgw!imagine!pawl22.pawl.rpi.edu!jesup From: jesup@pawl22.pawl.rpi.edu (Randell E. Jesup) Newsgroups: comp.sys.amiga Subject: Re: Need help with signals Message-ID: <192@imagine.PAWL.RPI.EDU> Date: 3 Jan 88 03:54:29 GMT References: <8801030156.AA04670@cory.Berkeley.EDU> Sender: news@imagine.PAWL.RPI.EDU Reply-To: beowulf!lunge!jesup@steinmetz.UUCP Organization: RPI Public Access Workstation Lab - Troy, NY Lines: 33 In article <8801030156.AA04670@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU (Matt Dillon) writes: > Now, assumming that SerRead and ConRead are each message ports the > rest of the code looks correct (at least what you've given us). In > fact, your use of GetMsg() is one of the more interesting ways to > check for IO completion (and remove the message from the reply port > if the IO has completed). In the case of the code below, it only > works if each request has its own reply port, which yours do. > > Most advanced programmers use only one reply port for all their > requests and use CheckIO()/WaitIO() instead of GetMsg(). One thing you forgot, Matt: for the userport (or any port where multiple messages may accumulate) the code should look like this: while(whatever) { mask = Wait(...); if (mask & (1L << UserPortSigBit)) while ((msg = GetMsg(UserPort)) != NULL) { process message } } Note that the 'while' is what I'm refering to. You MUST clear out all messages from the port when you get woken up, as the signal bit has been cleared. If you only clear one per awakening, and you are ever sent two, you'll always be one behind. If you are SURE that the port can only have one message in it, ok. Even then I like to use the while loop anyways. // Randell Jesup Lunge Software Development // Dedicated Amiga Programmer 13 Frear Ave, Troy, NY 12180 \\// lunge!jesup@beowulf.UUCP (518) 272-2942 \/ (uunet!steinmetz!beowulf!lunge!jesup)