Re: IPC and counters

2008-10-16 Thread Paul Makepeace
On Thu, Oct 16, 2008 at 7:36 AM, Philip Newton <[EMAIL PROTECTED]> wrote: > On Wed, Oct 15, 2008 at 02:01, Simon Wistow <[EMAIL PROTECTED]> wrote: >> Child: >> >> my ($msg, $sem_id) = get_message(); >> my $sem = IPC::Semaphore->new($sem_id); >> if (0 == $sem->op(0, -1, IPC_NOWAIT))

Re: IPC and counters

2008-10-15 Thread Philip Newton
On Wed, Oct 15, 2008 at 02:01, Simon Wistow <[EMAIL PROTECTED]> wrote: > Child: > > my ($msg, $sem_id) = get_message(); > my $sem = IPC::Semaphore->new($sem_id); > if (0 == $sem->op(0, -1, IPC_NOWAIT)) { > do_something($message); > } > > # If we're the last then cle

Re: IPC and counters

2008-10-14 Thread Simon Wistow
On Wed, Oct 15, 2008 at 12:08:43AM +0100, me said: Tell a lie, what I want is Parent: my $id = $message->id; my $n = scalar(@children); my $sem = IPC::Semaphore->new(IPC_PRIVATE, 2, IPC_CREAT); $sem->setall(1, $n-1); foreach my $child (@children) { $chil

Re: IPC and counters

2008-10-14 Thread Simon Wistow
On Tue, Oct 14, 2008 at 11:39:22PM +0100, Paul Makepeace said: > Isn't this exactly what semaphores are for? > > http://perldoc.perl.org/IPC/Semaphore.html > (http://en.wikipedia.org/wiki/Semaphores) Hah! The original subject of my post was "IPC and semaphores" but I changed it lest I do one of

Re: IPC and counters

2008-10-14 Thread Paul Makepeace
Isn't this exactly what semaphores are for? http://perldoc.perl.org/IPC/Semaphore.html (http://en.wikipedia.org/wiki/Semaphores) I'm sure you know all this so I suspect I've misread your question :-) P On Tue, Oct 14, 2008 at 11:21 PM, Simon Wistow <[EMAIL PROTECTED]> wrote: > > I have an IPC p

IPC and counters

2008-10-14 Thread Simon Wistow
I have an IPC problem. I have a parent process with a bunch of forked children. The parent sits in a loop waiting for messages and occasionally passes them onto the children which are also sitting in their own loops listening for messages and then doing stuff with them. Still with me? Now oc