home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3c / sem_open.z / sem_open
Encoding:
Text File  |  2002-10-03  |  11.6 KB  |  198 lines

  1.  
  2.  
  3.  
  4. sssseeeemmmm____ooooppppeeeennnn((((3333CCCC))))                                                      sssseeeemmmm____ooooppppeeeennnn((((3333CCCC))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      _ssss_eeee_mmmm______oooo_pppp_eeee_nnnn - open a posix named semaphore
  10.  
  11. CCCC SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_eeee_mmmm_aaaa_pppp_hhhh_oooo_rrrr_eeee_...._hhhh_>>>>
  13.      _ssss_eeee_mmmm______tttt _****_ssss_eeee_mmmm______oooo_pppp_eeee_nnnn _((((_cccc_oooo_nnnn_ssss_tttt _cccc_hhhh_aaaa_rrrr _****_n_a_m_e_,,,, _iiii_nnnn_tttt _o_f_l_a_g_,,,, _...._...._.... _////_**** _mmmm_oooo_dddd_eeee______tttt _m_o_d_e_,,,, _iiii_nnnn_tttt
  14.      _v_a_l_u_e _****_////_))))_;;;;
  15.  
  16. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  17.      _ssss_eeee_mmmm______oooo_pppp_eeee_nnnn opens a semaphore named by the character string at address _n_a_m_e.
  18.  
  19.      The _o_f_l_a_g parameter is used when creating a semaphore, supporting the
  20.      following bit flags:
  21.  
  22.      _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT
  23.           If the semaphore already exists, this flag has no effect, except as
  24.           noted under _OOOO______EEEE_XXXX_CCCC_LLLL below. Otherwise, the semaphore is created.  The
  25.           initial value of the semaphore may be specified by _v_a_l_u_e, where
  26.           _v_a_l_u_e is any non-negative number less than {SEM_VALUE_MAX} [see
  27.           _ssss_yyyy_ssss_cccc_oooo_nnnn_ffff(3C)].
  28.  
  29.           Named semaphores are represented by files in the file namespace
  30.           (commands like _llll_ssss will display named semaphores as regular files).
  31.           Because of this relationship, named semaphores inherit their access
  32.           semantics from files.  The owner ID of the semaphore is set to the
  33.           effective user IDs of the process, the group ID of the semaphore is
  34.           set to the effective group IDs of the process or to the group ID of
  35.           the directory in which the semaphore is being created. This is
  36.           determined as follows:
  37.  
  38.                If the underlying filesystem was mounted with the BSD file
  39.                creation semantics flag [see _ffff_ssss_tttt_aaaa_bbbb(4)] or the _SSSS______IIII_SSSS_GGGG_IIII_DDDD bit is
  40.                set [see _cccc_hhhh_mmmm_oooo_dddd(2)] on the parent directory, then the group ID
  41.                of the new file is set to the group ID of the parent directory,
  42.                otherwise it is set to the effective group ID of the calling
  43.                process.
  44.  
  45.                If the group ID of the semaphore does not match the effective
  46.                group ID, or one of the supplementary groups IDs, the _SSSS______IIII_SSSS_GGGG_IIII_DDDD
  47.                bit is cleared.  The access permission bits of the file mode
  48.                are set to the value of _m_o_d_e, modified as follows:
  49.  
  50.                     All bits set in the file mode creation mask of the process
  51.                     are cleared [see _uuuu_mmmm_aaaa_ssss_kkkk(2)].
  52.  
  53.                     The ``save text image after execution bit'' of the mode is
  54.                     cleared [see _cccc_hhhh_mmmm_oooo_dddd(2)].
  55.  
  56.      _OOOO______EEEE_XXXX_CCCC_LLLL  If _OOOO______EEEE_XXXX_CCCC_LLLL and _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT are set, _ssss_eeee_mmmm______oooo_pppp_eeee_nnnn will fail if the named
  57.              semaphore exists. The check for the existence of the semaphore
  58.              and the creation of the name in the file namespace is atomic with
  59.              respect to other processes executing _ssss_eeee_mmmm______oooo_pppp_eeee_nnnn naming the same
  60.  
  61.  
  62.                                                                         PPPPaaaaggggeeee 1111
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. sssseeeemmmm____ooooppppeeeennnn((((3333CCCC))))                                                      sssseeeemmmm____ooooppppeeeennnn((((3333CCCC))))
  70.  
  71.  
  72.  
  73.              semaphore in the same directory with _OOOO______EEEE_XXXX_CCCC_LLLL and _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT set.
  74.  
  75.      If a named semaphore is opened multiple times by the same process (or
  76.      threads within the process) before _ssss_eeee_mmmm______uuuu_nnnn_llll_iiii_nnnn_kkkk is called, the same
  77.      semaphore descriptor is returned from each call to _s_e_m__o_p_e_n.
  78.  
  79.      Named semaphores persist until the semaphore is unlinked and all other
  80.      references are dropped [see _ssss_eeee_mmmm______uuuu_nnnn_llll_iiii_nnnn_kkkk(2) and _ssss_eeee_mmmm______cccc_llll_oooo_ssss_eeee(2)].
  81.  
  82.      If _n_a_m_e is a symbolic link and _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT and _OOOO______EEEE_XXXX_CCCC_LLLL are set, the link is
  83.      not followed.
  84.  
  85.      There is a system enforced limit on the number of open named semaphores
  86.      per process _{{{{______PPPP_OOOO_SSSS_IIII_XXXX______SSSS_EEEE_MMMM______NNNN_SSSS_EEEE_MMMM_SSSS______MMMM_AAAA_XXXX_}}}}.
  87.  
  88.      If the character string pointed to by _n_a_m_e is prefixed with _////_dddd_eeee_vvvv, then
  89.      unpredictable results may occur.  Devices are opened using the _oooo_pppp_eeee_nnnn(2)
  90.      function.
  91.  
  92.      POSIX semaphores are compatible across all MIPS ABIs: o32, n32 and 64.
  93.  
  94.      Once a named semaphore is opened, the process may execute the following
  95.      semaphore operations: _ssss_eeee_mmmm______pppp_oooo_ssss_tttt, _ssss_eeee_mmmm______wwww_aaaa_iiii_tttt, _ssss_eeee_mmmm______tttt_rrrr_yyyy_wwww_aaaa_iiii_tttt, _ssss_eeee_mmmm______gggg_eeee_tttt_vvvv_aaaa_llll_uuuu_eeee,
  96.      _ssss_eeee_mmmm______uuuu_nnnn_llll_iiii_nnnn_kkkk, _ssss_eeee_mmmm______cccc_llll_oooo_ssss_eeee.
  97.  
  98.      _ssss_eeee_mmmm______oooo_pppp_eeee_nnnn will fail if one or more of the following are true:
  99.  
  100.      [EACCES]       The semaphore, named by _n_a_m_e, does not exist and write
  101.                     permission is denied by the parent directory of the
  102.                     semaphore to be created.
  103.  
  104.      [EACCES]       _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT is specified and write permission is denied.
  105.  
  106.      [EACCES]       A component of the _n_a_m_e prefix denies search permission.
  107.  
  108.      [EACCES]       _o_f_l_a_g permission is denied for an existing semaphore.
  109.  
  110.      [EAGAIN]       The semaphore exists, _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT is specified, mandatory
  111.                     file/record locking is set, and there are outstanding
  112.                     record locks on the file naming the semaphore [see
  113.                     _cccc_hhhh_mmmm_oooo_dddd(2)].
  114.  
  115.      [EDQUOT]       _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT is specified, the semaphore does not exist, and
  116.                     the directory in which the entry for the new semaphore is
  117.                     being placed cannot be extended either because the user's
  118.                     quota of disk blocks on the file system containing the
  119.                     directory has been exhausted or the user's quota of inodes
  120.                     on the file system on which the file is being created has
  121.                     been exhausted.
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                                                                         PPPPaaaaggggeeee 2222
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135. sssseeeemmmm____ooooppppeeeennnn((((3333CCCC))))                                                      sssseeeemmmm____ooooppppeeeennnn((((3333CCCC))))
  136.  
  137.  
  138.  
  139.      [EEXIST]       _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT and _OOOO______EEEE_XXXX_CCCC_LLLL are set, and the semaphore already
  140.                     exists.
  141.  
  142.      [EFAULT]       _n_a_m_e points outside the allocated address space of the
  143.                     process.
  144.  
  145.      [EINTR]        A signal was caught during the _ssss_eeee_mmmm______oooo_pppp_eeee_nnnn system call.
  146.  
  147.      [EINVAL]       _o_f_l_a_g_s specified _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT and _v_a_l_u_e was greater than
  148.                     {SEM_VALUE_MAX}.
  149.  
  150.      [EISDIR]       The semaphore _n_a_m_e points to a directory.
  151.  
  152.      [ELOOP]        Too many symbolic links were encountered in translating
  153.                     _n_a_m_e.
  154.  
  155.      [EMFILE]       The process has too many open semaphore or file
  156.                     descriptors [see _gggg_eeee_tttt_rrrr_llll_iiii_mmmm_iiii_tttt(2)].
  157.  
  158.      [ENAMETOOLONG] The length of the _n_a_m_e argument exceeds {_PPPP_AAAA_TTTT_HHHH______MMMM_AAAA_XXXX}, or the
  159.                     length of a _n_a_m_e component exceeds {_NNNN_AAAA_MMMM_EEEE______MMMM_AAAA_XXXX} while
  160.                     {______PPPP_OOOO_SSSS_IIII_XXXX______NNNN_OOOO______TTTT_RRRR_UUUU_NNNN_CCCC} is in effect.
  161.  
  162.      [ENFILE]       The system file table is full.
  163.  
  164.      [ENOENT]       _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT is not set and the semaphore does not exist.
  165.  
  166.      [ENOENT]       _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT is set and a component of the _n_a_m_e prefix does not
  167.                     exist or is the null pathname.
  168.  
  169.      [ENOSPC]       The system resources for semaphore allocation have been
  170.                     depleted.
  171.  
  172.      [ENOTDIR]      A component of the _n_a_m_e prefix is not a directory.
  173.  
  174.      [ETIMEDOUT]    The semaphore is located on a remote system which is not
  175.                     available [see _iiii_nnnn_tttt_rrrr_oooo(2)].
  176.  
  177.      [EROFS]        The named semaphore resides on a read-only file system,
  178.                     _OOOO______CCCC_RRRR_EEEE_AAAA_TTTT is set in _o_f_l_a_g, and the semaphore does not exist.
  179.  
  180. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  181.      sem_getvalue(3C), sem_post(3C), sem_wait(3C), sem_trywait(3C),
  182.      sem_open(3C), sem_close(3C), sem_unlink(3C), sysconf(3C)
  183.  
  184. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  185.      Upon successful completion, the address of the semaphore is returned.
  186.      Otherwise, a value of -1 is returned and _eeee_rrrr_rrrr_nnnn_oooo is set to indicate the
  187.      error.
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.                                                                         PPPPaaaaggggeeee 3333
  195.  
  196.  
  197.  
  198.