auto release of semaphores can be problematic

From: Date: Tue, 07 May 2002 15:51:36 +0000
Subject: auto release of semaphores can be problematic
Groups: php.dev 
Request: Send a blank email to php-dev+get-83795@lists.php.net to get a copy of this message
There is a bug report that states that the following cannot be implemented in PHP because of the semaphore auto-release on process exit feature: READER: p(mutex); readcount++; if (readcount is 1) then p(db); // marks db for auto-release v(mutex); CRITICAL REGION where we read p(mutex); readcount--; // Only release if no-one else is reading if (readcount is 0) then v(db); v(mutex); When the script has finished, PHP will vacate the db semaphore automatically, but that will screw up synchronization with the writer which will just acquire the db semaphore and start writing while there are still readers... Does anyone know of any good reason why we can't put a flag into the sysvsem_sem struct that says not to bother with auto-releasing? --Wez. -- Wez Furlong The Brain Room Ltd.

« previous php.dev (#83795) next »