Xref: utzoo comp.lang.c:9475 comp.unix.xenix:2053 Path: utzoo!mnetor!uunet!ncc!alberta!att-ih!chinet!les From: les@chinet.UUCP (Leslie Mikesell) Newsgroups: comp.lang.c,comp.unix.xenix Subject: Re: Interprocess Communication on UNIX SVR3 Message-ID: <4873@chinet.UUCP> Date: 19 Apr 88 18:38:12 GMT References: <2592@ihuxv.ATT.COM> Reply-To: les@chinet.UUCP (Leslie Mikesell) Distribution: na Organization: Chinet - Public Access Unix Lines: 19 Keywords: Producer/Consumer Problem In article <2592@ihuxv.ATT.COM> bareta@ihuxv.ATT.COM (Benyukhis) writes: > >Can anyone outthere help me code the producer/consumer problem >in "C". The prolog is as follows: the producer has to produce >a char and deposit it in the shareable buffer for consumer to pick it up >from. Both processes must use binary semaphores as a means of >synchronization. This sounds like you could use a pipe and avoid the need for any semaphores. If this is a simple 1 to 1 arrangement, you can just write producer to output to stdout, and consumer to read from stdin. Then let the shell set up the pipe with "producer | consumer". Or, one program can fork off a child process with a pipe connected (popen() will do it all for you). If you have multiple producers/one consumer or they cannot have the same parent process, you can use a FIFO or named pipe (see mknod(1) and mknod(2)). Les Mikesell