OSDN Git Service

(split) LDP: Update the version to 3.53 in PO files
[linuxjm/LDP_man-pages.git] / release / man3 / clock_getcpuclockid.3
1 .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\"*******************************************************************
27 .\"
28 .\" This file was generated with po4a. Translate the source file.
29 .\"
30 .\"*******************************************************************
31 .TH CLOCK_GETCPUCLOCKID 3 2013\-07\-04 Linux "Linux Programmer's Manual"
32 .SH 名前
33 clock_getcpuclockid \- プロセスの CPU 時刻のクロック ID を取得する
34 .SH 書式
35 \fB#include <time.h>\fP
36 .nf
37 .sp
38 \fBint clock_getcpuclockid(pid_t \fP\fIpid\fP\fB, clockid_t *\fP\fIclock_id\fP\fB);\fP
39 .fi
40 .sp
41 \fI\-lrt\fP とリンクする (バージョン 2.17 より前の glibc のみ)
42 .sp
43 .ad l
44 .in -4n
45 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
46 .in
47 .sp
48 \fBclock_getcpuclockid\fP():
49 .RS 4
50 _XOPEN_SOURCE\ >=\ 600 || _POSIX_C_SOURCE\ >=\ 200112L
51 .RE
52 .ad
53 .SH 説明
54 \fBclock_getcpuclockid\fP() 関数は、 プロセス ID が \fIpid\fP のプロセスの CPU 時刻のクロック ID を取得し、
55 その ID を \fIclock_id\fP が指す場所に入れて返す。 \fIpid\fP が 0 の場合、 呼び出し元のプロセスの CPU 時刻のクロック ID
56 が返される。
57 .SH 返り値
58 成功すると、 \fBclock_getcpuclockid\fP() は 0 を返す。 エラーの場合、
59 「エラー」の節のリストにある正のエラー番号のいずれかを返す。
60 .SH エラー
61 .TP 
62 \fBENOSYS\fP
63 カーネルが他のプロセスのプロセス単位の CPU 時刻のクロックの取得に対応しておらず、 かつ \fIpid\fP が呼び出し元のプロセスを指していなかった。
64 .TP 
65 \fBEPERM\fP
66 呼び出し元プロセスが \fIpid\fP で指定されたプロセスの CPU 時刻のクロックにアクセスする許可を持っていなかった。(POSIX.1\-2001
67 では任意のエラーとして規定されている。 カーネルが他のプロセスのプロセス単位の CPU 時刻のクロックの取得に対応していない場合には、
68 このエラーは発生しない。)
69 .TP 
70 \fBESRCH\fP
71 ID が \fIpid\fP のプロセスが存在しない。
72 .SH バージョン
73 \fBclock_getcpuclockid\fP() 関数は glibc バージョン 2.2 以降で利用可能である。
74 .SH 属性
75 .SS "マルチスレッディング (pthreads(7) 参照)"
76 \fBclock_getcpuclockid\fP() 関数はスレッドセーフである。
77 .SH 準拠
78 POSIX.1\-2001.
79 .SH 注意
80 \fIpid\fP に 0 を指定して \fBclock_getcpuclockid\fP() を呼び出して得られたクロック ID を引き数として
81 \fBclock_gettime\fP(2) の呼び出すのは、 クロック ID \fBCLOCK_PROCESS_CPUTIME_ID\fP を使って
82 \fBclock_gettime\fP(2) の呼び出すのと同じである。
83 .SH 例
84 以下のサンプルプログラムは、 コマンドラインで指定された ID を持つプロセスの CPU 時刻のクロック ID を取得し、
85 \fBclock_gettime\fP(2) を使ってそのクロックの時刻を取得する。 以下は実行例である。
86 .in +4n
87 .nf
88
89 $\fB ./a.out 1\fP                 # Show CPU clock of init process
90 CPU\-time clock for PID 1 is 2.213466748 seconds
91 .fi
92 .in
93 .SS プログラムのソース
94 \&
95 .nf
96 #define _XOPEN_SOURCE 600
97 #include <stdio.h>
98 #include <unistd.h>
99 #include <stdlib.h>
100 #include <time.h>
101
102 int
103 main(int argc, char *argv[])
104 {
105     clockid_t clockid;
106     struct timespec ts;
107
108     if (argc != 2) {
109         fprintf(stderr, "%s <process\-ID>\en", argv[0]);
110         exit(EXIT_FAILURE);
111     }
112
113     if (clock_getcpuclockid(atoi(argv[1]), &clockid) != 0) {
114         perror("clock_getcpuclockid");
115         exit(EXIT_FAILURE);
116     }
117
118     if (clock_gettime(clockid, &ts) == \-1) {
119         perror("clock_gettime");
120         exit(EXIT_FAILURE);
121     }
122
123     printf("CPU\-time clock for PID %s is %ld.%09ld seconds\en",
124             argv[1], (long) ts.tv_sec, (long) ts.tv_nsec);
125     exit(EXIT_SUCCESS);
126 }
127 .fi
128 .SH 関連項目
129 \fBclock_getres\fP(2), \fBtimer_create\fP(2), \fBpthread_getcpuclockid\fP(3),
130 \fBtime\fP(7)
131 .SH この文書について
132 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
133 である。プロジェクトの説明とバグ報告に関する情報は
134 http://www.kernel.org/doc/man\-pages/ に書かれている。