Be aware that there is no way to ensure that you have exclusive access to a lock, despite setting max_acquire=1.
In example,
<?
$fp = sem_get(fileinode('lock_file', 100);
sem_acquire($fp);
$fp2 = sem_get(fileinode('lock_file', 1);
sem_acquire($fp2);
?>
This will not block on the second sem_aquire. Therefore, if you have functions or processes that utilize shared locks (>1 max_acquire) you will still need to provide a seperate lock mechanism (ie flock) for write access, making the sem_ functions useless.
Some more info, in flock, each reference to the lock file has it's own options (can be shared exclusive blocking non blocking etc), but apparently php's sem functions only support these options per semaphore, not per semaphore-reference.