php3-list | 199901
Date: 01/31/99
- Next message: Rick Wiggins: "Re: [PHP3] FreeType Support with FreeBSD returns "Document contains no data""
- Previous message: oekoinstitut.plan <email protected>: "[PHP3] problems with image calls"
- In reply to: Richard Lynch: "Re: [PHP3] making dynamic pages pseudo dynamic, reducing sql load"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello Richard,
On 31-Jan-99 00:28:59, you wrote:
>At 3:31 PM 1/30/99, Manuel Lemos wrote:
>> Usually the parent gets a system private semaphore and shares the key
>> with child processes. The way semaphore support is now that can't work
>> that way in PHP. You have to explicitly pick semaphore key numbers so
>> that the same keys are used by all the concurrent page accesses. If I am
>> figuring this right, the problem is that this doesn't seem to prevent
>> semaphore reuse by unrelated processes.
>I don't know if I'm understanding the issues or if it's infeasible for some
>other reason, but it sound to me like you could generate a semaphore key
>using uniqueid() and somehow pass that key around among whomever should be
>sharing it...
Well, for a start, semaphore keys are numbers, not strings. I guess the
right way to prevent arbitrary use of the same key is to play with
semaphore permissions.
>I guess you can't guarantee that some other non-PHP Unix process wouldn't
>happen to pick the exact same key... Perhaps you should use
>md5(uniqueid()), which reduces the odds to something like 1 in a billion.
>An exact figure was computed in this mailing list a while back...
The way I see this should work is to add support for private semaphores
(IPC_PRIVATE usually key = 0). When you ask for a private semaphore I
assume the system gets a key that was not yet requested. The problem is
that currently there is no way feasable way to share private semaphore keys
by concurrent Web server processes using PHP.
You could think of using shared memory, but the access to shared memory has
to be arbitrated using semaphores to prevent the problems of concurrent
access.
So, the idea that I had was to have PHP semaphore extension to do the
following:
- On initialization allocate one private key to share with any Web server
process.
- Create an associative array (in C, not PHP) that stores the private keys
for named semaphores defined by the PHP scripts.
- So, when an application asks for a private semaphore, it would pass to a
function named sem_get_named(), a name that is unique enough for your
application, like "Superbowl score cache manager".
- The sem_get_named() function would acquire the initially allocated
semaphore in order to grant safe access to the named semaphores
associative arrays.
- If the requested named semaphore wouldn't exist, a new entry in the
associative array would be created and the newly created private
semaphore would be stored on that entry.
- If the requested named semaphore exists, it would simply return the
respective key.
I think this is a way to make semaphores work safe and usefully in PHP.
Regards,
Manuel Lemos
E-mail: mlemos <email protected>
URL: http://www.e-na.net/the_author.html
PGP key: finger://mlemos <email protected>
---- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>
- Next message: Rick Wiggins: "Re: [PHP3] FreeType Support with FreeBSD returns "Document contains no data""
- Previous message: oekoinstitut.plan <email protected>: "[PHP3] problems with image calls"
- In reply to: Richard Lynch: "Re: [PHP3] making dynamic pages pseudo dynamic, reducing sql load"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

