uTools-Manuals/docs/php/sem_get.html
2019-04-08 23:22:26 +08:00

134 lines
4.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Get a semaphore id</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.sem-get" class="refentry">
<div class="refnamediv">
<h1 class="refname">sem_get</h1>
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">sem_get</span> &mdash; <span class="dc-title">Get a semaphore id</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.sem-get-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>sem_get</strong></span>
( <span class="methodparam"><span class="type">int</span> <code class="parameter">$key</code></span>
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$max_acquire</code><span class="initializer"> = 1</span></span>
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$perm</code><span class="initializer"> = 0666</span></span>
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$auto_release</code><span class="initializer"> = 1</span></span>
]]] ) : <span class="type">resource</span></div>
<p class="para rdfs-comment">
<span class="function"><strong>sem_get()</strong></span> returns an id that can be used to
access the System V semaphore with the given <code class="parameter">key</code>.
</p>
<p class="para">
A second call to <span class="function"><strong>sem_get()</strong></span> for the same key
will return a different semaphore identifier, but both
identifiers access the same underlying semaphore.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.sem-get-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">key</code></dt>
<dd>
<p class="para">
</p>
</dd>
<dt>
<code class="parameter">max_acquire</code></dt>
<dd>
<p class="para">
The number of processes that can acquire the semaphore simultaneously
is set to <code class="parameter">max_acquire</code>.
</p>
</dd>
<dt>
<code class="parameter">perm</code></dt>
<dd>
<p class="para">
The semaphore permissions. Actually this value is
set only if the process finds it is the only process currently
attached to the semaphore.
</p>
</dd>
<dt>
<code class="parameter">auto_release</code></dt>
<dd>
<p class="para">
Specifies if the semaphore should be automatically released on request
shutdown.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.sem-get-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
Returns a positive semaphore identifier on success, or <strong><code>FALSE</code></strong> on
error.
</p>
</div>
<div class="refsect1 notes" id="refsect1-function.sem-get-notes">
<h3 class="title">注释</h3>
<div class="warning"><strong class="warning">Warning</strong>
<p class="simpara">
When using <span class="function"><strong>sem_get()</strong></span> 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 <em>nsems</em>
parameter when calling the C <em>semget()</em> function),
otherwise PHP will be unable to access the semaphore.
</p>
</div>
</div>
<div class="refsect1 seealso" id="refsect1-function.sem-get-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="sem_acquire.html" class="function" rel="rdfs-seeAlso">sem_acquire()</a> - Acquire a semaphore</span></li>
<li class="member"><span class="function"><a href="sem_release.html" class="function" rel="rdfs-seeAlso">sem_release()</a> - Release a semaphore</span></li>
<li class="member"><span class="function"><a href="ftok.html" class="function" rel="rdfs-seeAlso">ftok()</a> - Convert a pathname and a project identifier to a System V IPC key</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>