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
|
'\" t
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (C) 2006 Michael Kerrisk <mtk-manpages@gmx.net>
.\"
.\" 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.
.\"
.\" 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>
.\"
.TH SEM_OVERVIEW 7 2006-03-25 "Linux 2.6.16" "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Ĥη롣
.SS ̾դޥե
̾դޥե
.I /somename
Ȥ̾Ǽ̤롣
.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)
ȤäƤΥޥեƥफ뤳ȤǤ롣
.SS ̾ʤޥե (١ޥե)
̾ʤޥե̾ʤꡢޥեϡ
ʣåɴ֤Ƕͭ줿ΰ衢⤷ʣץ֤
ͭ줿ΰ֤ (Ԥ
.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)
Ȥäƥޥե˴٤Ǥ롣
.SH Linux ͭξܺٻ
.SS С
С 2.6 ΥͥǤϡLinux
̾ʤΥåɶͭޥեΤߤݡȤƤ
Linux 2.6 NPTL åɼƤ glibc ä
ƥǤϡPOSIX ޥեδʼ롣
.SS ³
POSIX ̾դޥեϥͥݻ롣
.BR sem_unlink ()
ǺʤСޥե
ƥबåȥޤ¸ߤ³롣
.SS
POSIX ޥե API Ѥץ
.I cc \-lrt
ǥѥ뤷ꥢ륿饤֥
.I librt
ȥʤФʤʤ
.SS ե륷ƥͳǤ̾դޥեؤΥ
Linux Ǥϡ̾դޥեϲۥե륷ƥ
(virtual file system)
.I \fBsem.\fPname
Ȥ̾Ǻ롣ۥե륷ƥ̾
.I /dev/shm
ʲ˥ޥȤ롣
.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_init (3),
.BR sem_getvalue (3),
.BR sem_open (3),
.BR sem_post (3),
.BR sem_unlink (3),
.BR sem_wait (3),
.BR pthreads (7)
|