.\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk .\" .\" .\" 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. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH TIMER_SETTIME 2 2009\-02\-20 Linux "Linux Programmer's Manual" .SH 名前 timer_settime, timer_gettime \- arm/disarm and fetch state of POSIX per\-process timer .SH 書式 .nf \fB#include \fP \fBint timer_settime(timer_t \fP\fItimerid\fP\fB, int \fP\fIflags\fP\fB,\fP \fB const struct itimerspec *\fP\fInew_value\fP\fB,\fP \fB struct itimerspec * \fP\fIold_value\fP\fB);\fP \fBint timer_gettime(timer_t \fP\fItimerid\fP\fB, struct itimerspec *\fP\fIcurr_value\fP\fB);\fP .fi Link with \fI\-lrt\fP. .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBtimer_settime\fP(), \fBtimer_gettime\fP(): _POSIX_C_SOURCE\ >=\ 199309L .SH 説明 \fBtimer_settime\fP() arms or disarms the timer identified by \fItimerid\fP. The \fInew_value\fP argument is an \fIitimerspec\fP structure that specifies the new initial value and the new interval for the timer. The \fIitimerspec\fP structure is defined as follows: .in +4n .nf struct timespec { time_t tv_sec; /* Seconds */ long tv_nsec; /* Nanoseconds */ }; struct itimerspec { struct timespec it_interval; /* Timer interval */ struct timespec it_value; /* Initial expiration */ }; .fi .in Each of the substructures of the \fIitimerspec\fP structure is a \fItimespec\fP structure that allows a time value to be specified in seconds and nanoseconds. These time values are measured according to the clock that was specified when the timer was created by \fBtimer_create\fP(2) If \fInew_value\->it_value\fP specifies a nonzero value (i.e., either subfield is nonzero), then \fBtimer_settime\fP() arms (starts) the timer, setting it to initially expire at the given time. (If the timer was already armed, then the previous settings are overwritten.) If \fInew_value\->it_value\fP specifies a zero value (i.e., both subfields are zero), then the timer is disarmed. The \fInew_value\->it_interval\fP field specifies the period of the timer, in seconds and nanoseconds. If this field is nonzero, then each time that an armed timer expires, the timer is reloaded from the value specified in \fInew_value\->it_interval\fP. If \fInew_value\->it_interval\fP specifies a zero value then the timer expires just once, at the time specified by \fIit_value\fP. .\" By experiment: the overrun count is set correctly, for CLOCK_REALTIME. By default, the initial expiration time specified in \fInew_value\->it_value\fP is interpreted relative to the current time on the timer's clock at the time of the call. This can be modified by specifying \fBTIMER_ABSTIME\fP in \fIflags\fP, in which case \fInew_value\->it_value\fP is interpreted as an absolute value as measured on the timer's clock; that is, the timer will expire when the clock value reaches the value specified by \fInew_value\->it_value\fP. If the specified absolute time has already passed, then the timer expires immediately, and the overrun count (see \fBtimer_getoverrun\fP(2)) will be set correctly. .\" Similar remarks might apply with respect to process and thread CPU time .\" clocks, but these clocks are not currently (2.6.28) settable on Linux. If the value of the \fBCLOCK_REALTIME\fP clock is adjusted while an absolute timer based on that clock is armed, then the expiration of the timer will be appropriately adjusted. Adjustments to the \fBCLOCK_REALTIME\fP clock have no effect on relative timers based on that clock. If \fIold_value\fP is not NULL, then it returns the previous interval of the timer (in \fIold_value\->it_interval\fP) and the amount of time until the timer would previously have next expired (in \fIold_value\->it_value\fP). \fBtimer_gettime\fP() returns the time until next expiration, and the interval, for the timer specified by \fItimerid\fP, in the buffer pointed to by \fIcurr_value\fP. The time remaining until the next timer expiration is returned in \fIcurr_value\->it_value\fP; this is always a relative value, regardless of whether the \fBTIMER_ABSTIME\fP flag was used when arming the timer. If the value returned in \fIcurr_value\->it_value\fP is zero, then the timer is currently disarmed. The timer interval is returned in \fIcurr_value\->it_interval\fP. If the value returned in \fIcurr_value\->it_interval\fP is zero, then this is a "one\-shot" timer. .SH 返り値 On success, \fBtimer_settime\fP() and \fBtimer_gettime\fP() return 0. On error, \-1 is returned, and \fIerrno\fP is set to indicate the error. .SH エラー These functions may fail with the following errors: .TP \fBEFAULT\fP \fInew_value\fP, \fIold_value\fP, or \fIcurr_value\fP is not a valid pointer. .TP \fBEINVAL\fP .\" FIXME . eventually: invalid value in flags \fItimerid\fP is invalid. .PP \fBtimer_settime\fP() may fail with the following errors: .TP \fBEINVAL\fP \fInew_value.it_value\fP is negative; or \fInew_value.it_value.tv_nsec\fP is negative or greater than 999,999,999. .SH バージョン These system calls are available since Linux 2.6. .SH 準拠 POSIX.1\-2001. .SH 例 See \fBtimer_create\fP(2). .SH 関連項目 \fBtimer_create\fP(2), \fBtimer_getoverrun\fP(2), \fBtime\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。