1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
'\" t
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
.\" Translated 2006-04-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2008-08-07, Akihiro MOTOKI, LDP v3.05
.\" Updated 2009-02-23, Akihiro MOTOKI, LDP v3.19
.\"
.TH SEM_OVERVIEW 7 2009-02-25 "Linux" "Linux Programmer's Manual"
.SH ̾
sem_overview \- POSIX ޥեγ
.SH
POSIX ޥեѤȡץ䥹åɴ֤Ǥư
Ʊ뤳ȤǤ롣
ޥեǤꡢͤϷ褷 0 ̤ˤʤ뤳Ȥϵʤ
ޥեФƤǤ 2 ĤǤ:
ޥեͤ 1 䤹
.RB ( sem_post (3));
ޥեͤ 1 餹
.RB ( sem_wait (3))
ޥեͤǤ 0 ξ硢ޥեͤ 0 礭ʤޤ
.BR sem_wait (3)
(block) 롣
POSIX ޥեˤϡ̾դޥե (named semaphore)
̾ʤޥե (unnamed semaphore) 2Ĥη롣
.TP
.B ̾դޥե
̾դޥե
.I /somename
Ȥ̾Ǽ̤롣
̾ϡ
.BI NAME_MAX \-4
(ʤ 251) ʸ NULL ü줿ʸǡ
.\" glibc allows the initial slash to be omitted, and makes
.\" multiple initial slashes equivalent to a single slash.
.\" This differs from the implementation of POSIX message queues.
åǻϤޤꡢåʳʸ 1 ʸʾ³Ǥ롣
.\" glibc allows subdirectory components in the name, in which
.\" case the subdirectory tree must exist under /dev/shm, and
.\" the fist subdirectory component must exist as the name
.\" sem.name, and all of the subdirectory components must allow the
.\" required permissions if a user wants to create a semaphore
.\" object in a subdirectory.
.BR sem_open (3)
Ʊ̾ϤȤˤꡢ2 ĤΥץ֤Ʊ̾Υޥե
ФԤȤǤ롣
.BR sem_open (3)
ؿϡ̾դޥե뤫¸ߤ̾դ
ޥեץ롣
ޥեץϡ
.BR sem_post (3)
.BR sem_wait (3)
ȤäƥޥեǤ롣
ץޥեλѤݤϡ
.BR sem_close (3)
ȤäƥޥեǤ롣
륻ޥեɤΥץѤʤʤȡ
.BR sem_unlink (3)
ȤäƤΥޥեƥफ뤳ȤǤ롣
.TP
.B ̾ʤޥե (١ޥե)
̾ʤޥե̾ʤꡢޥեϡ
ʣåɴ֤Ƕͭ줿ΰ衢⤷ʣץ֤
ͭ줿ΰ֤ (Ԥ
.IR "åɶͭޥե (thread-shared semaphore)"
Ԥ
.IR "ץͭޥե (process-shared semaphore)"
ȸƤ)åɶͭޥեϡƱץΥåɴ֤Ƕͭ줿
ΰ衢㤨ѿ (global variable) ֤롣
ץͭޥեϡͭΰ (㤨С
.BR semget (2)
ȤäƺǤ System V ͭꡦȤ
.BR shm_open (3)
ȤäƺǤ POSIX ͭꡦ֥)
֤ʤФʤʤ
̾ʤޥեϡѤ
.BR sem_init (3)
ȤäƽʤФʤʤ
ޥե
.BR sem_post (3)
.BR sem_wait (3)
ȤäǤ롣
ޥեϤɬפʤʤäȤ䡢
ޥե֤Ƥˤϡ
.BR sem_destroy (3)
Ȥäƥޥե˴٤Ǥ롣
.PP
λĤǤϡPOSIX ޥե Linux μξܺ
ˤĤ롣
.SS С
С 2.6 ΥͥǤϡLinux
̾ʤΥåɶͭޥեΤߤݡȤƤ
Linux 2.6 NPTL åɼƤ glibc ä
ƥǤϡPOSIX ޥեδʼ롣
.SS ³
POSIX ̾դޥեϥͥݻ롣
.BR sem_unlink (3)
ǺʤСޥե
ƥबåȥޤ¸ߤ³롣
.SS
POSIX ޥե API Ѥץ
.I cc \-lrt
ǥѥ뤷ꥢ륿饤֥
.I librt
ȥʤФʤʤ
.SS ե륷ƥͳǤ̾դޥեؤΥ
Linux Ǥϡ̾դޥեϲۥե륷ƥ
(virtual file system)
.I \fBsem.\fPsomename
Ȥ̾Ǻ롣ۥե륷ƥ̾
.I /dev/shm
ʲ˥ޥȤ롣
(줬ޥե̾ʸξ¤
.B NAME_MAX
ǤϤʤ
.BI NAME_MAX \-4
ȤʤäƤͳǤ롣)
Linux 2.6.19 ʹߤǤϡΥǥ쥯ȥ۲ΥեФ ACL
Ǥ֥ȤؤεĤ桼ñ̡롼ñ̤椹뤳Ȥ
Ǥ롣
.SH
POSIX.1-2001.
.SH
System V ޥե
.RB ( semget (2),
.BR semop (2)
ʤ) ϸŤޥե API Ǥ롣 POSIX ޥե System V
ñǡޤ߷פ줿եƤ롣
ǡPOSIX ޥե System V ޥե٤
ѤǤ륷ƥबʤ (äˡŤƥǤϾʤ)
.SH
Ƽ POSIX ޥեؿѤ㤬
.BR sem_wait (3)
˵ܤƤ롣
.SH Ϣ
.BR sem_close (3),
.BR sem_destroy (3),
.BR sem_getvalue (3),
.BR sem_init (3),
.BR sem_open (3),
.BR sem_post (3),
.BR sem_unlink (3),
.BR sem_wait (3),
.BR pthreads (7)
|