UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2008-11-18 09:52 PM

lvasilis22
Member
Registered: 2008-11-17
Posts: 8

Re: semaphores

If i create 3 shared memory segments (using shmget,shmat...e.t.c) is it better to control them using one semaphore set with 3 semaphores or to use 3 semaphore sets having one semaphore each?
I have one patern process and tree child processes. So, i want to exchange data between each child process and the patern process. Which of the two methods is better? Can i use them both?

Offline

#2 2008-11-19 04:20 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: semaphores

One semaphore set.

After a fork(2) the child inherits the attached shared memory segments.
So you only need to setup the shared memory stuff once before doing the forks
and the childs don't have to do anything at all. The same is probably true for
semaphores as well, but not sure about that.

But as Rob said in another post, if you want to transfer data and need to
synchronize and everything, using pipes or unix domain sockets might be
a much better idea...

Offline

#3 2009-08-15 03:17 PM

0788629219
Guest

Re: semaphores

Board footer

Powered by FluxBB