note 71164 added to ref.sem

From: Date: Tue, 14 Nov 2006 14:15:25 +0000
Subject: note 71164 added to ref.sem
Groups: php.notes 
Request: Send a blank email to php-notes+get-119723@lists.php.net to get a copy of this message
I have been trying to get a php console script and a C application to use a common semaphore for a while. I just got it working, so I thought Id paste the code here incase anyone needs to do this, however, this is not the place for long code examples I used c code from the php implementation to set up the semaphore set and then mimic the way the php interpreter implements a mutext type locking scheme, using a common semop call. One has to do the process in the same way as its done in the php implementation, otherwise you run the risk of the php interpreter resetting the semaphore set for you. The basic idea is. 1) sem_get - use a three semaphore set 1.1) increment the first sem 1.2) check the usage count (sem 3), if only one, set the max_attach using sem 2 for mutex behaviour to sem 3 2) decrement sem 1 3) for locking / unlocking use the first semaphore, but always call the above from your c-code. If you want a copy of my code, email me and I'll happily send it to you ! ---- Server IP: 66.163.161.117 Probable Submitter: 168.209.98.43 (proxied: 10.0.0.118, 196.209.63.194) ---- Manual Page -- http://www.php.net/manual/en/ref.sem.php Edit -- https://master.php.net/note/edit/71164 Del: integrated -- https://master.php.net/note/delete/71164/integrated Del: useless -- https://master.php.net/note/delete/71164/useless Del: bad code -- https://master.php.net/note/delete/71164/bad+code Del: spam -- https://master.php.net/note/delete/71164/spam Del: non-english -- https://master.php.net/note/delete/71164/non-english Del: in docs -- https://master.php.net/note/delete/71164/in+docs Del: other reasons-- https://master.php.net/note/delete/71164 Reject -- https://master.php.net/note/reject/71164 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119723) next »