<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Semaphore, Shared Memory and IPC Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="函数参考" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="SDO_DAS_Relational::executeQuery" HREF="function.sdo-das-relational-executequery.html"><LINK REL="NEXT" TITLE="ftok" HREF="function.ftok.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.sdo-das-relational-executequery.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ftok.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.sem" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CXLVI. Semaphore, Shared Memory and IPC Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN205365" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.intro" >简介</A ></H1 ><P > This module provides wrappers for the System V IPC family of functions. It includes semaphores, shared memory and inter-process messaging (IPC). </P ><P > Semaphores may be used to provide exclusive access to resources on the current machine, or to limit the number of processes that may simultaneously use a resource. </P ><P > This module provides also shared memory functions using System V shared memory. Shared memory may be used to provide access to global variables. Different httpd-daemons and even other programs (such as Perl, C, ...) are able to access this data to provide a global data-exchange. Remember, that shared memory is NOT safe against simultaneous access. Use semaphores for synchronization. <DIV CLASS="table" ><A NAME="AEN205371" ></A ><P ><B >表 1. Limits of Shared Memory by the Unix OS</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><TBODY ><TR ><TD >SHMMAX</TD ><TD >max size of shared memory, normally 131072 bytes</TD ></TR ><TR ><TD >SHMMIN</TD ><TD >minimum size of shared memory, normally 1 byte</TD ></TR ><TR ><TD >SHMMNI</TD ><TD > max amount of shared memory segments on a system, normally 100 </TD ></TR ><TR ><TD >SHMSEG</TD ><TD > max amount of shared memory segments per process, normally 6 </TD ></TR ></TBODY ></TABLE ></DIV > </P ><P > The messaging functions may be used to send and receive messages to/from other processes. They provide a simple and effective means of exchanging data between processes, without the need for setting up an alternative using Unix domain sockets. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B >本扩展模块在 Windows 平台下不可用。</P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.requirements" >需求</A ></H1 ><P >要编译本扩展模块无需外部库文件。</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.installation" >安装</A ></H1 ><P > Support for this functions are not enabled by default. To enable System V semaphore support compile PHP with the option <CODE CLASS="option" >--enable-sysvsem</CODE >. To enable the System V shared memory support compile PHP with the option <CODE CLASS="option" >--enable-sysvshm</CODE >. To enable the System V messages support compile PHP with the option <CODE CLASS="option" >--enable-sysvmsg</CODE >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.configuration" >运行时配置</A ></H1 ><P >这些函数的行为受 <TT CLASS="filename" >php.ini</TT > 的影响。</P ><P > <DIV CLASS="table" ><A NAME="AEN205404" ></A ><P ><B >表 2. Semaphore Configuration Options</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><COL><THEAD ><TR ><TH >Name</TH ><TH >Default</TH ><TH >Changeable</TH ><TH >Changelog</TH ></TR ></THEAD ><TBODY ><TR ><TD >sysvmsg.value</TD ><TD >"42"</TD ><TD >PHP_INI_ALL</TD ><TD > </TD ></TR ><TR ><TD >sysvmsg.string</TD ><TD >"foobar"</TD ><TD >PHP_INI_ALL</TD ><TD > </TD ></TR ></TBODY ></TABLE ></DIV > 有关 PHP_INI_* 常量进一步的细节与定义参见<A HREF="ini.html" >附录 H</A >。 </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.resources" >资源类型</A ></H1 ><P > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.constants" >预定义常量</A ></H1 ><P >以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。</P ><P > <DIV CLASS="table" ><A NAME="AEN205432" ></A ><P ><B >表 3. System V message constants</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><THEAD ><TR ><TH >Constant</TH ><TH >Type</TH ><TH >Changelog</TH ></TR ></THEAD ><TBODY ><TR ><TD >MSG_IPC_NOWAIT</TD ><TD ><A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></TD ><TD > </TD ></TR ><TR ><TD >MSG_EAGAIN</TD ><TD ><A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></TD ><TD >As of 5.2.0</TD ></TR ><TR ><TD >MSG_ENOMSG</TD ><TD ><A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></TD ><TD >As of 5.2.0</TD ></TR ><TR ><TD >MSG_NOERROR</TD ><TD ><A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></TD ><TD > </TD ></TR ><TR ><TD >MSG_EXCEPT</TD ><TD ><A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></TD ><TD > </TD ></TR ></TBODY ></TABLE ></DIV > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >目录</B ></DT ><DT ><A HREF="function.ftok.html" >ftok</A > -- Convert a pathname and a project identifier to a System V IPC key </DT ><DT ><A HREF="function.msg-get-queue.html" >msg_get_queue</A > -- Create or attach to a message queue </DT ><DT ><A HREF="function.msg-receive.html" >msg_receive</A > -- Receive a message from a message queue </DT ><DT ><A HREF="function.msg-remove-queue.html" >msg_remove_queue</A > -- Destroy a message queue </DT ><DT ><A HREF="function.msg-send.html" >msg_send</A > -- Send a message to a message queue </DT ><DT ><A HREF="function.msg-set-queue.html" >msg_set_queue</A > -- Set information in the message queue data structure </DT ><DT ><A HREF="function.msg-stat-queue.html" >msg_stat_queue</A > -- Returns information from the message queue data structure </DT ><DT ><A HREF="function.sem-acquire.html" >sem_acquire</A > -- Acquire a semaphore</DT ><DT ><A HREF="function.sem-get.html" >sem_get</A > -- Get a semaphore id</DT ><DT ><A HREF="function.sem-release.html" >sem_release</A > -- Release a semaphore</DT ><DT ><A HREF="function.sem-remove.html" >sem_remove</A > -- Remove a semaphore</DT ><DT ><A HREF="function.shm-attach.html" >shm_attach</A > -- Creates or open a shared memory segment</DT ><DT ><A HREF="function.shm-detach.html" >shm_detach</A > -- Disconnects from shared memory segment</DT ><DT ><A HREF="function.shm-get-var.html" >shm_get_var</A > -- Returns a variable from shared memory</DT ><DT ><A HREF="function.shm-put-var.html" >shm_put_var</A > -- Inserts or updates a variable in shared memory </DT ><DT ><A HREF="function.shm-remove-var.html" >shm_remove_var</A > -- Removes a variable from shared memory </DT ><DT ><A HREF="function.shm-remove.html" >shm_remove</A > -- Removes shared memory from Unix systems</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.sdo-das-relational-executequery.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ftok.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >SDO_DAS_Relational::executeQuery</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ftok</TD ></TR ></TABLE ></DIV ></BODY ></HTML >