getitimer.2

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 119 行

2
119
字号
.\" SCCSID: @(#)getitimer.2	3.2	12/15/87.TH getitimer 2.SH Namegetitimer, setitimer \- get or set value of interval timer.SH Syntax.nf.ft B#include <sys/time.h>.PP.ft B#define ITIMER_REAL   	0	/* real time intervals */#define ITIMER_VIRTUAL	1	/* virtual time intervals */#define ITIMER_PROF   	2	/* user and system virtual time */.sp.ft Bgetitimer(which, value)int which;struct itimerval *value;.PP.ft Bsetitimer(which, value, ovalue)int which;struct itimerval *value, *ovalue;.fi.SH Description.NXR "getitimer system call".NXR "setitimer system call".NXR "interval timer" "getting value".NXR "interval timer" "setting value"The system provides each process with three interval timers,defined in <sys/time.h>.The.PN getitimercall returns the current value for the timer specified in.IR which ,while the.PN setitimercall sets the value of a timer (optionally, returning the previousvalue of the timer).The upper limit for time values are as follows:.sp.in 1.0iFor VAX machines, 10millisec * 0x7fffffff  (about 256 days).brFor RISC machines, 3.906 millsec * 0x7fffffff (about 97 days).in -1.0i.PPA timer value is defined by the .I itimervalstructure:.EX 0struct itimerval {      struct  timeval it_interval; /* timer interval */      struct  timeval it_value;    /* current value */};.EE.PPIf.I it_valueis nonzero, it indicates the time to the next timer expiration. If.I it_intervalis nonzero, it specifies a value to be used in reloading .I it_valuewhen the timer expires.Setting .I it_valueto 0 disables a timer.  Setting .I it_intervalto 0 causes a timer to be disabled after its next expiration (assuming.I it_valueis nonzero)..PPTime values smaller than the resolution of thesystem clock are rounded up to this resolution(on MIPS, 3.906 milliseconds; on VAX, 10 milliseconds)..PPThe ITIMER_REAL timer decrements in real time.  A SIGALRM signal isdelivered when this timer expires..NXR "interval timer" "types".PPThe ITIMER_VIRTUAL timer decrements in process virtual time.It runs only when the process is executing.  A SIGVTALRM signalis delivered when it expires..PPThe ITIMER_PROF timer decrements both in process virtual time andwhen the system is running on behalf of the process.  It is designedto be used by interpreters in statistically profiling the executionof interpreted programs.Each time the ITIMER_PROF timer expires, the SIGPROF signal isdelivered.  Because this signal may interrupt in-progresssystem calls, programs using this timer must be prepared torestart interrupted system calls..PPThree macros for manipulating time values are defined in <sys/time.h>.The.I timerclearsets a time value to zero,.I timerissettests if a time value is nonzero, and.I timercmpcompares two time values (beware that >= and <= do notwork with this macro)..SH Return ValuesIf the calls succeed, a value of 0 is returned.  If an error occurs,the value \-1 is returned, and a more precise error code is placedin the global variable, \fIerrno\fP..SH DiagnosticsThe possible errors are:.TP 15[EFAULT]The \fIvalue\fP structure specified a bad address..TP 15[EINVAL]A \fIvalue\fP structure specified a time that was too largeto be handled..SH See Alsogettimeofday(2), sigvec(2), pause(3)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?