ScotlandPHP

sem_get

(PHP 4, PHP 5, PHP 7)

sem_getGet a semaphore id

Description

resource sem_get ( int $key [, int $max_acquire = 1 [, int $perm = 0666 [, int $auto_release = 1 ]]] )

sem_get() returns an id that can be used to access the System V semaphore with the given key.

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

Parameters

key

max_acquire

The number of processes that can acquire the semaphore simultaneously is set to max_acquire.

perm

The semaphore permissions. Actually this value is set only if the process finds it is the only process currently attached to the semaphore.

auto_release

Specifies if the semaphore should be automatically released on request shutdown.

Return Values

Returns a positive semaphore identifier on success, or FALSE on error.

Notes

Warning

When using sem_get() to access a semaphore created outside PHP, note that the semaphore must have been created as a set of 3 semaphores (for example, by specifying 3 as the nsems parameter when calling the C semget() function), otherwise PHP will be unable to access the semaphore.

See Also

add a note add a note

User Contributed Notes 10 notes

03136izeon.semdiv clavallunctio>
n">up Bug
n">
<

V 03136iphp" tit77% likeally ...iztio> 5/ul>

n"> "> &ss=";onaio <

n">
<

V 18174iphp" tit60% likeally ...iztio> 1/ul>

n"> ">
n">
<

V 19114iphp" tit100% likeally ...iztio> 2/ul> n"> ">
n">
<

V 05537iphp" tit100% likeally ...iztio> 1/ul> n"> ">
Watch tMEoter wyou usemote ing><()aiedge">Geuniquo the semap r">s(g 3suggescreait some dfs-comasedlly tn> aally creaem> functait conjm> funcDore wvp'>Pot con Contsoftware: Invseems, es (for exampSVN PHP wid="chd to ing><. hp'>Ussuch aling fPHP wo_rvi you ore wy>rermuss=ouseales/'>Usinl.varyatme y>rerFilesy's the semap poo wilandlingstal="cilaemr o e="pmptsfierge">Get a semaphPHP wfte.m hpe ipcs tme ipc Comsdfrommandux-efs.-ndl(ot most di() on
n">
<

V69249iphp" tit100% likeally ...iztio> 1/ul> n"> ">
n">
<

V31756iphp" titno vallu...iztio> 0/ul> n"> ">
n">
<

V31741iphp" titno vallu...iztio> 0/ul> n"> ">
ef="http://ecum-csuchico.edu/~beej/gu ae/ipc/shmem.99/xonaiobr />sem_get

on
n">
<

V82920tphp" tit0% likeally ...iztio> -2/ul> n"> ">
I exaDocumentahof rd ond-writitive semaphonwise:

 , , , ,
 , ,age.c  , ,age.c  , ,
 , , ,  ,* @ to accprivp'>
 ,  ,* @ ty pe">reso -rmuss=oe a semaphbr /> ,  ,*/
 , ,D , ,
 , , ,  ,* @ to accprivp'>
 ,  ,* @ ty pe">reso -r ond/writitive semaphbr /> ,  ,*/
 , ,Dresource , ,
 , , ,  ,* @ to accprivp'>
 ,  ,* @ ty iomobr /> ,  ,*/
 , ,D , ,
 , , ,  ,* @ to accprivp'>
 ,  ,* @ ty iomobr /> ,  ,*/
 , ,D
 , , ,  ,* D"x-defaage.cl Stor
 ,  ,*
 ,  ,* Is="initiaallr ond/writitive semaphbr /> ,  ,*/
 , , funcD , , , ,s , , , ,reso_r">s , , , ,sem_get , , , ,reso sem_getreso_r"> , ,}
 , ,
 , , ,  ,* De.cl Stor
 ,  ,*
 ,  ,* Remgle llr ond/writitive semaphbr /> ,  ,*/
 , , funcD , , , ,semgle_get , , , ,semgle_getresource , ,}
 , ,
 , , ,  ,* Ron req ao acceoalle pe">reso
 ,  ,*
 ,  ,* @ p iom $mfe Mbr /> ,  ,* @ill retvoidobr /> ,  ,*/
 , ,Dem> funcD , , , ,if u , , , , , ,max_acquies , , , , , ,
 , , , , , ,U*/
 , , , , , , , , , , , ,
 , , , , , ,seo_releaes , , , , , ,max_acquiesresource , , , ,} else { , , , , , ,
 , , , , , ,max_acquies , , , , , ,if u , , , , , , , ,seo_releaes , , , , , , , ,max_acquiesresource , , , , , , , ,max_acquies , , , , , ,}
 , , , , , ,U*/
 , , , , , , , , , , , ,
 , , , , , ,seo_releaes , , , ,}
 , ,}
 , ,
 , ,privp'>Dem> funcD , , , ,if u , , , , , ,max_acquies , , , , , ,
 , , , , , ,U*/
 , , , , , , , , , , , ,
 , , , , , ,seo_releaes , , , , , ,seo_releaesresource , , , ,} else {
 , , , , , ,max_acquies , , , , , ,
 , , , , , ,U*/
 , , , , , , , , , , , ,
 , , , , , ,if u , , , , , , , ,seo_releaesresource , , , , , ,
 , , , , , ,seo_releaes , , , ,}
 , ,}
 , ,
 , , ,  ,* Ron req pendh to acceoalle pe">reso
 ,  ,*
 ,  ,* @ill retvoidobr /> ,  ,*/
 , , funcD , ,
 , , ,  ,* Roo_relfpendh to acceoalle pe">reso
 ,  ,*
 ,  ,* @ill retvoidobr /> ,  ,*/
 , , funcD , ,
 , , ,  ,* Ron req writit to acceoalle pe">reso
 ,  ,*
 ,  ,* @ill retvoidobr /> ,  ,*/
 , , funcD , ,
 , , ,  ,* Roo_relfwritit to acceoalle pe">reso
 ,  ,*
 ,  ,* @ill retvoidobr /> ,  ,*/
 , , funcD , ,
}
on
n">
<

V76000tphp" tit33% likeally ...iztio> -1/ul> n"> ">
n">
<

V89226iatp" tit25% likeally ...iztio> -4/ul> n"> ">