IPC and STREAMS in Unix V.3
Dave Turner
dmt at ptsfa.UUCP
Thu Mar 17 12:50:10 AEST 1988
In article <117 at amtfocus.UUCP> irab at amtfocus.UUCP (Ira Brenner) writes:
> I have four main processes running simultaneously (A, B, C, D). Process
> B needs to communicate with a child (C) and another process, which may
> or may not be a child, (D). No direct communication between C and D is
> necessary. Process B also needs to communicate with process A. In
> could use a few pointers on how to do it. I don't think any of
> the other methods of IPC for Unix (shared memory, semephores) are
System V messages will do what you want. Have each process open a message queue
for reading. The other processes can open the same msg queues for writing.
The message could contain the message id if replies are expected (required?).
A set of files can be used to allow the processes to open the msg queues.
Use ftok() (see stdipc(3c) to convert filenames to key-t's for msgget().
Give the files names that make sense to the set of processes.
/usr/spool/xxx/A # the msg queue read by process A
/usr/spool/xxx/B # the msg queue read by process B
/usr/spool/xxx/C # the msg queue read by process C
/usr/spool/xxx/D # the msg queue read by process D
Each process should ftok and get its msg queue first. Processes B-D should read
(and wait for) messages. Process only needs to read its msg queue occassionally
and probably should not wait.
--
Dave Turner 415/542-1299 {ihnp4,lll-crg,qantel,pyramid}!ptsfa!dmt
More information about the Comp.unix.questions
mailing list