Question about messages in SVR2
Stoll W William
wws at whuxlm.UUCP
Fri Nov 1 01:15:14 AEST 1985
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
More information about the Comp.unix.wizards
mailing list