Re: Semaphores - feature request
| From: | Wojciech Malota | Date: | Wed, 03 Jan 2007 08:43:55 +0000 |
| Subject: | Re: Semaphores - feature request | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-27247@lists.php.net to get a copy of this message | ||
> You must use some additional application specific logic to trigger
> semaphore removal. For example you could have a "boss" process that
> collects the exit status of each "worker". When the boss process has an
> exit status for all workers the semaphore can be removed.
>
> Am I getting closer or am I still not understanding the problem?
>
> Mike
You are much closer now.
I think that PHP interpreter should be a "boss" because PHP scripts don't
know if this execution of website is the last which releases the semaphore.
So if last script calls my_sem_release function, the semaphore will be
removed and now another script calls my_sem_acquire function it won't cause
an error because inside my_sem_acquire function is called sem_get() which
will create this semaphore once again. So this solution is completely safe.
I haven't got knowledge about PHP source code, so I can't implement this
behaviour - I give only an idea.
The key to success is that all instructions in functions my_sem_acquire and
my_sem_release can't be interrupted.
Wojciech Malota