OSDN Git Service

7bbd87419b732d0c90d7332a555d038a7e68ef12
[linuxjm/LDP_man-pages.git] / draft / man3 / sem_getvalue.3
1 '\" t
2 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\"
4 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"
26 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
27 .\" Translated 2006-04-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
28 .\"
29 .TH SEM_GETVALUE 3 2006-03-25 "Linux" "Linux Programmer's Manual"
30 .\"O .SH NAME
31 .SH 名前
32 .\"O sem_getvalue \- get the value of a semaphore
33 sem_getvalue \- セマフォの値を取得する
34 .\"O .SH SYNOPSIS
35 .SH 書式
36 .nf
37 .B #include <semaphore.h>
38 .sp
39 .BI "int sem_getvalue(sem_t *" sem ", int *" sval );
40 .fi
41 .sp
42 .\"O Link with \fI\-lrt\fP or \fI\-pthread\fP.
43 \fI\-lrt\fP または \fI\-pthread\fP でリンクする。
44 .\"O .SH DESCRIPTION
45 .SH 説明
46 .\"O .BR sem_getvalue ()
47 .\"O places the current value of the semaphore pointed to
48 .\"O .I sem
49 .\"O into the integer pointed to by
50 .\"O .IR sval .
51 .BR sem_getvalue ()
52 は、
53 .I sem
54 が指すセマフォの現在の値を
55 .I sval
56 で指す整数に格納する。
57
58 .\"O If one or more processes or threads are blocked
59 .\"O waiting to lock the semaphore with
60 .\"O .BR sem_wait (3),
61 .\"O POSIX.1-2001 permits two possibilities for the value returned in
62 .\"O .IR sval :
63 .\"O either 0 is returned;
64 .\"O or a negative number whose absolute value is the count
65 .\"O of the number of processes and threads currently blocked in
66 .\"O .BR sem_wait (3).
67 .\"O Linux adopts the former behavior.
68 POSIX.1-2001 によると、
69 1つ以上のプロセスかスレッドが
70 .BR sem_wait (3)
71 でセマフォのロック待ちで停止している場合、
72 .I sval
73 で返される値は 0 もしくは負の値のいずれかとなる。
74 負の値の場合、その絶対値は
75 .BR sem_wait (3)
76 で現在停止しているプロセスかスレッドの合計数に等しい。
77 Linux は前者の動作 (0 を返す動作) を採用している。
78 .\"O .SH RETURN VALUE
79 .SH 返り値
80 .\"O .BR sem_getvalue ()
81 .\"O returns 0 on success;
82 .\"O on error, \-1 is returned and
83 .\"O .I errno
84 .\"O is set to indicate the error.
85 成功すると、
86 .BR sem_getvalue ()
87 は 0 を返す。エラーの場合、\-1 を返し、
88 .I errno
89 にエラーを示す値をセットする。
90 .\"O .SH ERRORS
91 .SH エラー
92 .TP
93 .B EINVAL
94 .\"O .I sem
95 .\"O is not a valid semaphore.
96 .I sem
97 は有効なセマフォではない。
98 .\"O .SH CONFORMING TO
99 .SH 準拠
100 POSIX.1-2001.
101 .\"O .SH NOTES
102 .SH 注意
103 .\"O The value of the semaphore may already have changed by the time
104 .\"O .BR sem_getvalue ()
105 .\"O returns.
106 .BR sem_getvalue ()
107 が返るときには、すでにセマフォの値は変化している可能性がある。
108 .\"O .SH "SEE ALSO"
109 .SH 関連項目
110 .BR sem_post (3),
111 .BR sem_wait (3),
112 .BR sem_overview (7)