⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0764-0766.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Complete Command Reference:System Calls:EarthWeb Inc.-</TITLE>

</HEAD>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311046 //-->

<!-- TITLE=Linux Complete Command Reference//-->

<!-- AUTHOR=Red Hat//-->

<!-- PUBLISHER=Macmillan Computer Publishing//-->

<!-- IMPRINT=Sams//-->

<!-- CHAPTER=02 //-->

<!-- PAGES=0737-0890 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->



<P><CENTER>

<a href="0760-0763.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0767-0770.html">Next</A></CENTER></P>







<A NAME="PAGENUM-764"><P>Page 764</P></A>





<P><B>

DESCRIPTION

</B></P>



<P>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.

</P>



<TABLE>



<TR><TD>

ITIMER_REAL

</TD><TD>

Decrements in real time and delivers

SIGALRM upon expiration.

</TD></TR><TR><TD>

ITIMER_VIRTUAL

</TD><TD>

Decrements only when the process is executing, and delivers

SIGVTALRM upon expiration.

</TD></TR><TR><TD>

ITIMER_PROF

</TD><TD>

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.

</TD></TR></TABLE>



<P>Timer values are defined by the following structures:

</P>



<!-- CODE //-->

<PRE>

struct itimerval {

                struct timeval it_interval; /* next value */

                struct timeval it_value;    /* current value */

            };

            struct timeval {

                long tv_sec;                /* seconds */

                long tv_usec;               /* microseconds */

            };

</PRE>

<!-- END CODE //-->



<P>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.

</P>



<P>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.

</P>



<P>Both tv_sec and tv_usec are significant in determining the duration of a timer.

</P>



<P>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.

</P>



<P><B>

RETURN VALUE

</B></P>



<P>On success, 0 is returned. On error, _1 is returned and

errno is set appropriately.

</P>



<P><B>

ERRORS

</B></P>



<TABLE>



<TR><TD>

EFAULT

</TD><TD>

value and ovalue are not valid pointers.

</TD></TR><TR><TD>

EINVAL

</TD><TD>

which is not one of ITIMER_REAL,

ITIMER_VIRT, or ITIMER_PROF.

</TD></TR></TABLE>



<P><B>

SEE ALSO

</B></P>



<!-- CODE SNIP //-->

<PRE>

gettimeofday(2), sigaction(2), signal(2)

</PRE>

<!-- END CODE SNIP //-->



<P><B>

BUGS

</B></P>



<P>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.

</P>



<P>Linux 0.99.11, 5 August 1993

</P>



<A NAME="PAGENUM-765"><P>Page 765</P></A>





<H3><A NAME="ch02_ 35">

getpagesize

</A></H3>



<P>getpagesize&#151;Gets system page size

</P>



<P><B>

SYNOPSIS

</B></P>



<!-- CODE SNIP //-->

<PRE>

#include &lt;unistd.h&gt;

size_t getpagesize(void);

</PRE>

<!-- END CODE SNIP //-->



<P><B>

DESCRIPTION

</B></P>



<P>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.

</P>



<P><B>

NOTES

</B></P>



<P>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).

</P>



<P><B>

SEE ALSO

</B></P>



<!-- CODE SNIP //-->

<PRE>

sbrk(2)

</PRE>

<!-- END CODE SNIP //-->



<P>Linux 0.99.11, 23 July 1993

</P>



<H3><A NAME="ch02_ 36">

getpeername

</A></H3>



<P>getpeername&#151;Gets the name of the connected peer

</P>



<P><B>

SYNOPSIS

</B></P>



<!-- CODE SNIP //-->

<PRE>

int getpeername(int s, struct sockaddr

*name,int*namelen);

</PRE>

<!-- END CODE SNIP //-->



<P><B>

DESCRIPTION

</B></P>



<P>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.

</P>



<P><B>

RETURN VALUE

</B></P>



<P>On success, 0 is returned. On error, _1 is returned and

errno is set appropriately.

</P>



<P><B>

ERRORS

</B></P>



<TABLE>



<TR><TD>

EBADF

</TD><TD>

The argument s is not a valid descriptor.

</TD></TR><TR><TD>

ENOTSOCK

</TD><TD>

The argument s is a file, not a socket.

</TD></TR><TR><TD>

ENOTCONN

</TD><TD>

The socket is not connected.

</TD></TR><TR><TD>

ENOBUFS

</TD><TD>

Insufficient resources were available in the system to perform the operation.

</TD></TR><TR><TD>

EFAULT

</TD><TD>

The name parameter points to memory not in a valid part of the process address space.

</TD></TR></TABLE>



<P><B>

HISTORY

</B></P>



<P>The getpeername function call appeared in BSD 4.2.

</P>



<P><B>

SEE ALSO

</B></P>



<!-- CODE SNIP //-->

<PRE>

accept(2), bind(2), getsockname(2)

</PRE>

<!-- END CODE SNIP //-->



<P>BSD Man Page, 24 July 1993

</P>



<A NAME="PAGENUM-766"><P>Page 766</P></A>





<H3><A NAME="ch02_ 37">

getpid, getppid

</A></H3>



<P>getpid, getppid&#151;Gets process identification

</P>



<P><B>

SYNOPSIS

</B></P>



<!-- CODE SNIP //-->

<PRE>

#include &lt;unistd.h&gt;

pid_t getpid(void);

pid_t getppid(void);

</PRE>

<!-- END CODE SNIP //-->



<P><B>

DESCRIPTION

</B></P>



<P>getpid returns the process ID of the current process. (This is often used by routines that generate unique

temporary filenames.)

</P>



<P>getppid returns the process ID of the parent of the current process.

</P>



<P><B>

CONFORMS TO

</B></P>



<P>POSIX, BSD 4.3, SVID

</P>



<P><B>

SEE ALSO

</B></P>



<!-- CODE SNIP //-->

<PRE>

exec(2), fork(2), kill(2), mkstemp(3), tmpnam(3),

tempnam(3), tmpfile(3)

</PRE>

<!-- END CODE SNIP //-->



<P>Linux 0.99.11, 23 July 1993

</P>



<H3><A NAME="ch02_ 38">

getpriority, setpriority

</A></H3>



<P>getpriority, setpriority&#151;Gets/sets program scheduling priority

</P>



<P><B>

SYNOPSIS

</B></P>



<!-- CODE SNIP //-->

<PRE>

#include &lt;sys/time.h&gt;

#include &lt;sys/resource.h&gt;

int getpriority(int which,int who);

int setpriority(int which,int who,int prio);

</PRE>

<!-- END CODE SNIP //-->



<P><B>

DESCRIPTION

</B></P>



<P>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.

</P>



<P>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.

</P>



<P><B>

RETURNS VALUES

</B></P>



<P>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.

</P>



<P><B>

ERRORS

</B></P>



<TABLE>



<TR><TD>

ESRCH

</TD><TD>

No process was located using the

which and who values specified.

</TD></TR><TR><TD>

EINVAL

</TD><TD>

which was not one of PRIO_PROCESS,

PRIO_PGRP,or PRIO_USER.

</TD></TR></TABLE>







<P><CENTER>

<a href="0760-0763.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0767-0770.html">Next</A></CENTER></P>







</td>
</tr>
</table>

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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