Note that when you reset $sem_identifier the semaphore won't block anymore!
This code does NOT work:
$key = ftok(__FILE__,'m');
$a = sem_get($key);
sem_acquire($a);
$a = false;
while this one does:
$key = ftok(__FILE__,'m');
$a = sem_get($key);
sem_acquire($a);
//$a = false;
So: use unique var names for your identifier!