<HTML ><HEAD ><TITLE >Semaphore, Shared Memory and IPC Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Function Reference" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="sql_regcase" HREF="function.sql-regcase.html"><LINK REL="NEXT" TITLE="ftok" HREF="function.ftok.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></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 Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.sql-regcase.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ftok.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.sem" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XCI. Semaphore, Shared Memory and IPC Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN82240" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.intro" ></A >Introduction</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="AEN82246" ></A ><P ><B >Table 1. Limits of Shared Memory by the Unix OS</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >SHMMAX</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >max size of shared memory, normally 131072 bytes</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >SHMMIN</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >minimum size of shared memory, normally 1 byte</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >SHMMNI</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > max amount of shared memory segments on a system, normally 100 </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >SHMSEG</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > 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 >Note: </B >This extension is not available on Windows platforms.</P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.requirements" ></A >Requirements</H1 ><P >No external libraries are needed to build this extension.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.installation" ></A >Installation</H1 ><P > Support for this functions are not enabled by default. To enable System V semaphore support compile PHP with the option <TT CLASS="option" >--enable-sysvsem</TT >. To enable the System V shared memory support compile PHP with the option <TT CLASS="option" >--enable-sysvshm</TT >. To enable the System V messages support compile PHP with the option <TT CLASS="option" >--enable-sysvmsg</TT >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.configuration" ></A >Runtime Configuration</H1 ><P > The behaviour of these functions is affected by settings in <TT CLASS="filename" >php.ini</TT >. </P ><P > <DIV CLASS="table" ><A NAME="AEN82279" ></A ><P ><B >Table 2. Semaphore Configuration Options</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Name</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Default</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Changeable</TH ></TR ></THEAD ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >sysvmsg.value</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >"42"</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >PHP_INI_ALL</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >sysvmsg.string</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >"foobar"</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >PHP_INI_ALL</TD ></TR ></TBODY ></TABLE ></DIV > For further details and definition of the PHP_INI_* constants see <A HREF="function.ini-set.html" ><B CLASS="function" >ini_set()</B ></A >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.resources" ></A >Resource Types</H1 ><P > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="sem.constants" ></A >Predefined Constants</H1 ><P >This extension has no constants defined.</P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</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.sql-regcase.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ftok.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >sql_regcase</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ftok</TD ></TR ></TABLE ></DIV ></BODY ></HTML >