Annotation of 43BSDReno/share/doc/ps1/06.sysman/1.4.t, revision 1.1.1.1

1.1       root        1: .\" Copyright (c) 1983 Regents of the University of California.
                      2: .\" All rights reserved.  The Berkeley software License Agreement
                      3: .\" specifies the terms and conditions for redistribution.
                      4: .\"
                      5: .\"    @(#)1.4.t       6.2 (Berkeley) 5/12/86
                      6: .\"
                      7: .sh "Timers
                      8: .NH 3
                      9: Real time
                     10: .PP
                     11: The system's notion of the current Greenwich time and the current time
                     12: zone is set and returned by the call by the calls:
                     13: .DS
                     14: #include <sys/time.h>
                     15: 
                     16: settimeofday(tvp, tzp);
                     17: struct timeval *tp;
                     18: struct timezone *tzp;
                     19: 
                     20: gettimeofday(tp, tzp);
                     21: result struct timeval *tp;
                     22: result struct timezone *tzp;
                     23: .DE
                     24: where the structures are defined in \fI<sys/time.h>\fP as:
                     25: .DS
                     26: ._f
                     27: struct timeval {
                     28:        long    tv_sec; /* seconds since Jan 1, 1970 */
                     29:        long    tv_usec;        /* and microseconds */
                     30: };
                     31: 
                     32: struct timezone {
                     33:        int     tz_minuteswest; /* of Greenwich */
                     34:        int     tz_dsttime;     /* type of dst correction to apply */
                     35: };
                     36: .DE
                     37: The precision of the system clock is hardware dependent.
                     38: Earlier versions of UNIX contained only a 1-second resolution version
                     39: of this call, which remains as a library routine:
                     40: .DS
                     41: time(tvsec)
                     42: result long *tvsec;
                     43: .DE
                     44: returning only the tv_sec field from the \fIgettimeofday\fP call.
                     45: .NH 3
                     46: Interval time
                     47: .PP
                     48: The system provides each process with three interval timers,
                     49: defined in \fI<sys/time.h>\fP:
                     50: .DS
                     51: ._d
                     52: #define        ITIMER_REAL     0       /* real time intervals */
                     53: #define        ITIMER_VIRTUAL  1       /* virtual time intervals */
                     54: #define        ITIMER_PROF     2       /* user and system virtual time */
                     55: .DE
                     56: The ITIMER_REAL timer decrements
                     57: in real time.  It could be used by a library routine to
                     58: maintain a wakeup service queue.  A SIGALRM signal is delivered
                     59: when this timer expires.
                     60: .PP
                     61: The ITIMER_VIRTUAL timer decrements in process virtual time.
                     62: It runs only when the process is executing.  A SIGVTALRM signal
                     63: is delivered when it expires.
                     64: .PP
                     65: The ITIMER_PROF timer decrements both in process virtual time and when
                     66: the system is running on behalf of the process.
                     67: It is designed to be used by processes to statistically profile
                     68: their execution.
                     69: A SIGPROF signal is delivered when it expires.
                     70: .PP
                     71: A timer value is defined by the \fIitimerval\fP structure:
                     72: .DS
                     73: ._f
                     74: struct itimerval {
                     75:        struct  timeval it_interval;    /* timer interval */
                     76:        struct  timeval it_value;       /* current value */
                     77: };
                     78: .DE
                     79: and a timer is set or read by the call:
                     80: .DS
                     81: getitimer(which, value);
                     82: int which; result struct itimerval *value;
                     83: 
                     84: setitimer(which, value, ovalue);
                     85: int which; struct itimerval *value; result struct itimerval *ovalue;
                     86: .DE
                     87: The third argument to \fIsetitimer\fP specifies an optional structure
                     88: to receive the previous contents of the interval timer.
                     89: A timer can be disabled by specifying a timer value of 0.
                     90: .PP
                     91: The system rounds argument timer intervals to be not less than the
                     92: resolution of its clock.  This clock resolution can be determined
                     93: by loading a very small value into a timer and reading the timer back to
                     94: see what value resulted.
                     95: .PP
                     96: The \fIalarm\fP system call of earlier versions of UNIX is provided
                     97: as a library routine using the ITIMER_REAL timer.  The process
                     98: profiling facilities of earlier versions of UNIX
                     99: remain because
                    100: it is not always possible to guarantee
                    101: the automatic restart of system calls after 
                    102: receipt of a signal.
                    103: The \fIprofil\fP call arranges for the kernel to begin gathering
                    104: execution statistics for a process:
                    105: .DS
                    106: profil(buf, bufsize, offset, scale);
                    107: result char *buf; int bufsize, offset, scale;
                    108: .DE
                    109: This begins sampling of the program counter, with statistics maintained
                    110: in the user-provided buffer.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.