Sys V IPC

andy at coma.UUCP andy at coma.UUCP
Fri Feb 14 05:38:00 AEST 1986


> I have been reading the documentation for the Sys V IPC stuff (msg, shm)
> and it is not exactly crystal-clear (no kidding!)  Could anyone please provide
> me (and the net community) with one or several examples of message-passing
> between cooperating processes?

Indeed, the documentation of the Sys V IPC-package is not very
instructive.

It took me quite a time of reading and reading and reading the 
documentation and examining the Source-Code to understand how
it works. 

After a while I had my first success in managing semaphores --
it really works.

	- First you have to get an ipc-key with	"ftok".
	  "Ftok" takes as arguments a filename of an existing
	  file and a single letter and returns always the
	  same key if it gets the same arguments.

	- For creating a set of semaphores or a message queue
	  you have to use [sem|msg|shm]get with the flag 
	  IPC_CREATE.

	- Next, very important, you have to set the access-permissions
	  with [sem|msg|shm]ctl. See UPM (2), which structs
	  the ctl-calls expect as arguments.

	- If you have done this, you can use the [sem|msg|shm]op
	  calls and they will work.

	Note, that the steps 2 and 3 have to be done just once
	for each set of semaphores, message queue or segment of 
	shared memory. 
	For subsequent accesses you need a ...get call (to get
	the ipcID) instaed.

Up to now I made tests only with semaphores and message queues.
Semaphores work nearly correct. "Nearly" means, that they are
first in - last out !!!!!
I few days ago I made my first experiences with message queues
and I had some difficulties with long messages (loss of data).
Perhaps that was my mistake, messages that contain just a single
character arrive correctly.

					Good luck,
						   Andy

   Andreas Lampen 	 	\\	UUCP:	mcvax!unido!tub!coma!andy
   Techn. Univ. Berlin		 \\	 BITNET(EARN):	  lampen at db0tui11
   				  \\      Tel:		  +49-30-31473496
				   \\
			 	    Berlin, the city that never sleeps !!
			
		



More information about the Comp.unix mailing list