Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84 exptools; site whuxlm.UUCP
Path: utzoo!watmath!clyde!cbosgd!ihnp4!whuxlm!wws
From: wws@whuxlm.UUCP (Stoll W William)
Newsgroups: net.unix-wizards
Subject: Question about messages in SVR2
Message-ID: <862@whuxlm.UUCP>
Date: Thu, 31-Oct-85 10:15:14 EST
Article-I.D.: whuxlm.862
Posted: Thu Oct 31 10:15:14 1985
Date-Received: Sat, 2-Nov-85 03:56:38 EST
Distribution: net
Organization: AT&T Bell Laboratories, Whippany
Lines: 34

I have a question about how msgrcv calls are handled by the
system.  If several processes each call msgrcv with differing
negative mtypes and another process sends a message, who
gets first crack at the message?  Or can more than one process
receive the message?

For example, suppose

   |    proc A calls msgrcv() with mtype -3
 time   proc B calls msgrcv() with mtype -5
   |    proc C calls msgrcv() with mtype -1
   V    proc D calls msgsnd() with mtype 1

Who receives the message sent by proc D?  Here are my guesses
in decreasing order of probability (in my eyes anyway):

1) Any of A, B, and C may receive the message, depending on who
   happens to get the processor first.
2) Process A gets the message because it called msgrcv() first.
3) Process C gets the message because abs(-1) == mtype of the
   message that was sent.
4) All three processes (A, B, and C) get the message.

The reason I suspect guess (1) is that I peeked at msg.c and
it appears that when a message gets sent, a wakeup gets done
to all procs sleeping on that msqid_ds structure (or the system
equivalent -- I don't remember).  Since I would prefer that
guess (2) is correct (and it makes more sense to me), I hope
that somebody will tell me that I'm wrong.

Can anyone enlighten me here?  My apologies if this subject has
come up before; if so, please send private mail to

Bill Stoll, ihnp4!whuxlm!wws