Ask a Question related to UNIX Programming, Design and Development.
-
Roy Smith #1
Need help with semaphore creation/syncronization strategy.
I've been playing with System V IPC semaphores a bit, and I've come to a
point where I'm stuck.
I've got two processes (call them master and slave) which share a
semaphore. I'm using the race condition avoidance algorithm Stevens
describes in UNP Volume 2. The master creates a semaphore, initializes
it to zero (i.e. claims the lock), then does a semop() to force
sem_otime to go non-zero. The slave loops waiting for sem_otime.
The problem is, I don't know how to handle the case where a previous
master process may have died unexpectedly and left an orphaned semaphore
in the kernel. How would the slave recognize this condition? As far as
the slave can tell, the semaphore is initialized, so it assumes the
master is ready to go.
Roy Smith Guest
-
Process syncronization in perl?
I need to manage inter-process syncronization in perl. I'm running a multi-platform software build on 4 machines, all sharing a common NFS mounted... -
ANNOUNCE: POSIX::RT::Semaphore 0.01
POSIX::RT::Semaphore is a Perl interface to POSIX.1b (Realtime) semaphores, at least as supported by your system. ;-) RT semaphores are objects... -
Syncronization
Hello, Does anyone know how to syncronize a movieclip in two different flash movies. So that when you move from the first instance of the... -
semaphore example needed
Hi all, I tried to use IPC::Semaphore but tried for a long time without success. What I want to do is like this : I want to limit a perl... -
Semaphore tutorial?
Does anybody have a good tutorial for how SysV semaphores work, specifically the semop() function? I've read the description in Stevens' Unix... -
another2 #2
Re: Need help with semaphore creation/syncronization strategy.
okay, here's one way i thought of, i'm a bit of a newbie on semaphores
and i''ve only had experience with pthreads on solaris so if it's
stupid: i'm sorry
okay, i'd put a piece of code like this to figure out if the
server fails:
i used 2000 but, you may want a bigger number, the assumption is that
the server wont run 2000 times in one itteration of the client but, i
think i'm right with this code, if i'm wrong and you do get it please
post it, i like thread coding :)
int i = 2000;
//i used this to as an example if you wanna keep the thing
//running indefinitley
while(true)
{
if(sem_getvalue(&your_semaphore) == 0)
{
--i;
}
else
{
i = 2000;
sem_wait(&your_semaphore);
//your critical section
sem_post(&your_semaphore);
}
if (i < 1)
{
//server failed
}
}//end of while loop
--
Posted via [url]http://dbforums.com[/url]
another2 Guest



Reply With Quote

