<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.fileprocess.process.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'book.sem.php',
    1 => 'Semaphore',
    2 => 'Semaphore, Shared Memory and IPC',
  ),
  'up' => 
  array (
    0 => 'refs.fileprocess.process.php',
    1 => 'Process Control Extensions',
  ),
  'prev' => 
  array (
    0 => 'class.volatile.php',
    1 => 'Volatile',
  ),
  'next' => 
  array (
    0 => 'sem.setup.php',
    1 => 'Installing/Configuring',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/sem/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.sem.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.sem" class="book">
 
 <h1 class="title">Semaphore, Shared Memory and IPC</h1>
 

 
 <div id="intro.sem" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="simpara">
   These modules provide wrappers for the System V IPC family of functions.
   It includes semaphores, shared memory and inter-process messaging (IPC).
  </p>
  <p class="simpara">
   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 class="para">
   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.
   <table class="doctable table">
    <caption><strong>Limits of Shared Memory by the Unix OS</strong></caption>
    
     <tbody class="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>

  </p>
  <p class="simpara">
   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>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Only the shared memory functions and <span class="function"><a href="function.ftok.php" class="function">ftok()</a></span> are available
    on Windows. Neither semaphores nor inter-process messaging functions are
    supported on that platform.
   </span>
  </p></blockquote>
 </div>
 

 




 




 





 



 



 




<ul class="chunklist chunklist_book"><li><a href="sem.setup.php">Installing/Configuring</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="sem.installation.php">Installation</a></li><li><a href="sem.configuration.php">Runtime Configuration</a></li><li><a href="sem.resources.php">Resource Types</a></li></ul></li><li><a href="sem.constants.php">Predefined Constants</a></li><li><a href="ref.sem.php">Semaphore Functions</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="function.ftok.php">ftok</a> — Convert a pathname and a project identifier to a System V IPC key</li><li><a href="function.msg-get-queue.php">msg_get_queue</a> — Create or attach to a message queue</li><li><a href="function.msg-queue-exists.php">msg_queue_exists</a> — Check whether a message queue exists</li><li><a href="function.msg-receive.php">msg_receive</a> — Receive a message from a message queue</li><li><a href="function.msg-remove-queue.php">msg_remove_queue</a> — Destroy a message queue</li><li><a href="function.msg-send.php">msg_send</a> — Send a message to a message queue</li><li><a href="function.msg-set-queue.php">msg_set_queue</a> — Set information in the message queue data structure</li><li><a href="function.msg-stat-queue.php">msg_stat_queue</a> — Returns information from the message queue data structure</li><li><a href="function.sem-acquire.php">sem_acquire</a> — Acquire a semaphore</li><li><a href="function.sem-get.php">sem_get</a> — Get a semaphore id</li><li><a href="function.sem-release.php">sem_release</a> — Release a semaphore</li><li><a href="function.sem-remove.php">sem_remove</a> — Remove a semaphore</li><li><a href="function.shm-attach.php">shm_attach</a> — Creates or open a shared memory segment</li><li><a href="function.shm-detach.php">shm_detach</a> — Disconnects from shared memory segment</li><li><a href="function.shm-get-var.php">shm_get_var</a> — Returns a variable from shared memory</li><li><a href="function.shm-has-var.php">shm_has_var</a> — Check whether a specific entry exists</li><li><a href="function.shm-put-var.php">shm_put_var</a> — Inserts or updates a variable in shared memory</li><li><a href="function.shm-remove.php">shm_remove</a> — Removes shared memory from Unix systems</li><li><a href="function.shm-remove-var.php">shm_remove_var</a> — Removes a variable from shared memory</li></ul></li><li><a href="class.sysvmessagequeue.php">SysvMessageQueue</a> — The SysvMessageQueue class</li><li><a href="class.sysvsemaphore.php">SysvSemaphore</a> — The SysvSemaphore class</li><li><a href="class.sysvsharedmemory.php">SysvSharedMemory</a> — The SysvSharedMemory class</li></ul></div><?php manual_footer($setup); ?>