★ wanayoo — archive 1999 http://www.php.net/manual/function.sem-get.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Semaphore
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Semaphore
* sem_get
* sem_acquire
* sem_release
* shm_attach
* shm_detach
* shm_remove
* shm_put_var
* shm_get_var
* shm_remove_var
Manual: sem_get
View the source code for this pageSearch the site



Previous page
 Semaphore
 Updated
Sat, 12 Aug 2000
sem_acquire 
Next page


sem_get

(PHP3 >= 3.0.6, PHP4 )

sem_get -- Get a semaphore id

Description

int sem_get (int key [, int max_acquire [, int perm]])

Returns: A positive semaphore identifier on success, or false on error.

Sem_get() returns an id that can be used to access the System V semaphore with the given key. The semaphore is created if necessary using the permission bits specified in perm (defaults to 0666). The number of processes that can acquire the semaphore simultaneously is set to max_acquire (defaults to 1). Actually this value is set only if the process finds it is the only process currently attached to the semaphore.

A second call to sem_get() for the same key will return a different semaphore identifier, but both identifiers access the same underlying semaphore.

See also: sem_acquire() and sem_release().


User Contributed Notes: sem_get


h.raaf@i-k-c.net
25-Mar-1999 05:39
Notice that 'int key' for semaphores is shared with the keys used for shared-memory. So you get in trouble when you use the same key value for semaphores and shared memory!


oier@demasiado.com
17-Feb-2000 11:55
where is sem_remove function???
How can I remove a semaphore from my system????



zgshao99@sina.com
31-Mar-2000 06:16
Calling function sem_get(123).
but return msg "Fatal error: Call to undefined function: sem_get() in /usr/local/apache/htdocs/szg/t.php3 on line 2".
why?




shum_address@hotmail.com
28-Jun-2000 10:46
any example for sem_get, sem_acquire, sem_release? i dont know how to use semaphore in php? thanks.


jkelsey@freei.net
06-Jul-2000 10:32
There is no conflict between shared memory ids and semaphore ids. These are different entities and can have the same id. Many processes that use semaphores to control access to shared memory use the semaphore with a specific id to control access to the shared memory with the same id!

To remove semaphores, use the command-line function ipcrm.



amit@hostpro.net
14-Jul-2000 05:25
semaphores are temporary locks on a thread that you acquire when you want no other thread to mess with you data in memory. So that means that you dont need a sem_remove function. when you release the semaphore you allow other processes to touch that thread.


bible89@hotmail.com
25-Jul-2000 03:11
Hello. I can't understand how to use
semaphore in PHP
please, give me the sample code.
thanks.



dngkon@globalsources.com
26-Jul-2000 08:04
Fatal error: Call to unsupported or undefined function sem_get() in /d3/asmweb/php3/test.phtml on line 7

Why do I still get the above even though I use php4??
I cannot call sem_acquire()
or sem_release() either



 About Notes


Previous page
 Semaphore
 Updated
Sat, 12 Aug 2000
sem_acquire 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.