-->
Page 764
DESCRIPTION
The system provides each process with three interval timers, each decrementing in a distinct time domain. When any timer expires, a signal is sent to the process, and the timer (potentially) restarts.
ITIMER_REAL | Decrements in real time and delivers SIGALRM upon expiration. |
ITIMER_VIRTUAL | Decrements only when the process is executing, and delivers SIGVTALRM upon expiration. |
ITIMER_PROF | Decrements both when the process executes and when the system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space. SIGPROF is delivered upon expiration. |
Timer values are defined by the following structures:
struct itimerval { struct timeval it_interval; /* next value */ struct timeval it_value; /* current value */ }; struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */ };
getitimer(2) fills the structure indicated by value with the current setting for the timer indicated by which (one of ITIMER_REAL, ITIMER_VIRTUAL, or ITIMER_PROF). The element it_value is set to the amount of time remaining on the timer, or 0 if the timer is disabled. Similarly, it_interval is set to the reset value. setitimer(2) sets the indicated timer to the value in value. If ovalue is nonzero, the old value of the timer is stored there.
Timers decrement from it_value to 0, generate a signal, and reset to it_interval. A timer that is set to 0 (it_value is 0 or the timer expires and it_interval is 0) stops.
Both tv_sec and tv_usec are significant in determining the duration of a timer.
Timers will never expire before the requested time, instead expiring some short, constant time afterward, dependent on the system timer resolution (currently 10ms). Upon expiration, a signal will be generated and the timer reset. If the timer expires while the process is active (always true for ITIMER_VIRT), the signal will be delivered immediately when generated. Otherwise, the delivery will be offset by a small time dependent on the system loading.
RETURN VALUE
On success, 0 is returned. On error, _1 is returned and errno is set appropriately.
ERRORS
EFAULT | value and ovalue are not valid pointers. |
EINVAL | which is not one of ITIMER_REAL, ITIMER_VIRT, or ITIMER_PROF. |
SEE ALSO
gettimeofday(2), sigaction(2), signal(2)
BUGS
Under Linux, the generation and delivery of a signal are distinct and there each signal is permitted only one outstanding event. It's therefore conceivable that under pathologically heavy loading, ITIMER_REAL will expire before the signal from a previous expiration has been delivered. The second signal in such an event will be lost.
Linux 0.99.11, 5 August 1993
Page 765
getpagesizeGets system page size
SYNOPSIS
#include <unistd.h> size_t getpagesize(void);
DESCRIPTION
Returns the number of bytes in a page. This is the system's page size, which is not necessarily the same as the hardware page size.
NOTES
getpagesize is implemented as a library function in DLL 4.4.1. Depending on what is defined when the library is compiled, this function returns EXEC_PAGESIZE (set to 4096 in Linux 0.99.11), NBPG (set to 4096 in Linux 0.99.11), or NBPC (not defined in Linux 0.99.11 or DLL 4.4.1 libraries).
SEE ALSO
sbrk(2)
Linux 0.99.11, 23 July 1993
getpeernameGets the name of the connected peer
SYNOPSIS
int getpeername(int s, struct sockaddr *name,int*namelen);
DESCRIPTION
getpeername returns the name of the peer connected to socket s. The namelen parameter should be initialized to indicate the amount of space pointed to by name. On return it contains the actual size of the name returned (in bytes). The name is truncated if the buffer provided is too small.
RETURN VALUE
On success, 0 is returned. On error, _1 is returned and errno is set appropriately.
ERRORS
EBADF | The argument s is not a valid descriptor. |
ENOTSOCK | The argument s is a file, not a socket. |
ENOTCONN | The socket is not connected. |
ENOBUFS | Insufficient resources were available in the system to perform the operation. |
EFAULT | The name parameter points to memory not in a valid part of the process address space. |
HISTORY
The getpeername function call appeared in BSD 4.2.
SEE ALSO
accept(2), bind(2), getsockname(2)
BSD Man Page, 24 July 1993
Page 766
getpid, getppidGets process identification
SYNOPSIS
#include <unistd.h> pid_t getpid(void); pid_t getppid(void);
DESCRIPTION
getpid returns the process ID of the current process. (This is often used by routines that generate unique temporary filenames.)
getppid returns the process ID of the parent of the current process.
CONFORMS TO
POSIX, BSD 4.3, SVID
SEE ALSO
exec(2), fork(2), kill(2), mkstemp(3), tmpnam(3), tempnam(3), tmpfile(3)
Linux 0.99.11, 23 July 1993
getpriority, setpriorityGets/sets program scheduling priority
SYNOPSIS
#include <sys/time.h> #include <sys/resource.h> int getpriority(int which,int who); int setpriority(int which,int who,int prio);
DESCRIPTION
The scheduling priority of the process, process group, or user, as indicated by which and who, is obtained with the getpriority call and set with the setpriority call. which is one of PRIO_PROCESS, PRIO_PGRP,or PRIO_USER, and who is interpreted relative to which (a process identifier for PRIO_PROCESS, process group identifier for PRIO_PGRP, and a user ID for PRIO_USER). A 0 value of who denotes the current process, process group, or user. prio is a value in the range _20 to 20. The default priority is 0; lower priorities cause more favorable scheduling.
The getpriority call returns the highest priority (lowest numerical value) enjoyed by any of the specified processes. The setpriority call sets the priorities of all the specified processes to the specified value. Only the superuser may lower priorities.
RETURNS VALUES
Because getpriority can legitimately return the value _1, it is necessary to clear the external variable errno prior to the call, and then check it afterward to determine whether a _1 is an error or a legitimate value. The setpriority call returns 0 if there is no error, or _1 if there is.
ERRORS
ESRCH | No process was located using the which and who values specified. |
EINVAL | which was not one of PRIO_PROCESS, PRIO_PGRP,or PRIO_USER. |