mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-23 03:10:05 +00:00
Update.
* sysdeps/unix/bsd/times.c: Reorder includes and add <time.h>. (timeval_to_clock_t): Add clk_tck argument and use that instead of CLK_TCK. (__times): Use __getclktck to get the number of clock ticks per second and use its return value instead of CLK_TCK. 2001-02-10 Mark Kettenis <kettenis@gnu.org>
This commit is contained in:
parent
51410f1453
commit
87b56f36cc
@ -1,3 +1,11 @@
|
||||
2001-02-10 Mark Kettenis <kettenis@gnu.org>
|
||||
|
||||
* sysdeps/unix/bsd/times.c: Reorder includes and add <time.h>.
|
||||
(timeval_to_clock_t): Add clk_tck argument and use that instead of
|
||||
CLK_TCK.
|
||||
(__times): Use __getclktck to get the number of clock ticks per
|
||||
second and use its return value instead of CLK_TCK.
|
||||
|
||||
2001-02-10 Mark Kettenis <kettenis@gnu.org>
|
||||
|
||||
* sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h (_HAVE_SA_LEN): Define.
|
||||
|
@ -533,7 +533,7 @@ apply only to CPU time.
|
||||
CPU scheduling is a complex issue and different systems do it in wildly
|
||||
different ways. New ideas continually develop and find their way into
|
||||
the intricacies of the various systems' scheduling algorithms. This
|
||||
section discusses the general concepts, some specifics of systems
|
||||
section discusses the general concepts, some specifics of systems
|
||||
that commonly use the GNU C library, and some standards.
|
||||
|
||||
For simplicity, we talk about CPU contention as if there is only one CPU
|
||||
@ -620,7 +620,7 @@ tell you what the range is on a particular system.
|
||||
One thing you must keep in mind when designing real time applications is
|
||||
that having higher absolute priority than any other process doesn't
|
||||
guarantee the process can run continuously. Two things that can wreck a
|
||||
good CPU run are interrupts and page faults.
|
||||
good CPU run are interrupts and page faults.
|
||||
|
||||
Interrupt handlers live in that limbo between processes. The CPU is
|
||||
executing instructions, but they aren't part of any process. An
|
||||
@ -678,7 +678,7 @@ If two processes are ready to run but have different absolute priorities,
|
||||
the decision is much simpler, and is described in @ref{Absolute
|
||||
Priority}.
|
||||
|
||||
Each process has a scheduling policy. For processes with absolute
|
||||
Each process has a scheduling policy. For processes with absolute
|
||||
priority other than zero, there are two available:
|
||||
|
||||
@enumerate
|
||||
@ -792,7 +792,7 @@ The following macros represent the valid values for @var{policy}:
|
||||
@item SCHED_OTHER
|
||||
Traditional Scheduling
|
||||
@item SCHED_FIFO
|
||||
First In First Out
|
||||
First In First Out
|
||||
@item SCHED_RR
|
||||
Round Robin
|
||||
@end table
|
||||
@ -941,7 +941,7 @@ to this function are:
|
||||
|
||||
@comment sched.h
|
||||
@comment POSIX
|
||||
@deftypefun int sched_set_priority_max (int *@var{policy});
|
||||
@deftypefun int sched_get_priority_max (int *@var{policy});
|
||||
|
||||
This function returns the highest absolute priority value that is
|
||||
allowable for a process that with scheduling policy @var{policy}.
|
||||
@ -963,11 +963,11 @@ to this function are:
|
||||
@comment POSIX
|
||||
@deftypefun int sched_rr_get_interval (pid_t @var{pid}, struct timespec *@var{interval})
|
||||
|
||||
This function returns the length of the quantum (time slice) used with
|
||||
This function returns the length of the quantum (time slice) used with
|
||||
the Round Robin scheduling policy, if it is used, for the process with
|
||||
Process ID @var{pid}.
|
||||
|
||||
It returns the length of time as @var{interval}.
|
||||
It returns the length of time as @var{interval}.
|
||||
@c We need a cross-reference to where timespec is explained. But that
|
||||
@c section doesn't exist yet, and the time chapter needs to be slightly
|
||||
@c reorganized so there is a place to put it (which will be right next
|
||||
@ -1052,7 +1052,7 @@ immediately.
|
||||
|
||||
In addition to its absolute priority of zero, every process has another
|
||||
priority, which we will refer to as "dynamic priority" because it changes
|
||||
over time. The dynamic priority is meaningless for processes with
|
||||
over time. The dynamic priority is meaningless for processes with
|
||||
an absolute priority higher than zero.
|
||||
|
||||
The dynamic priority sometimes determines who gets the next turn on the
|
||||
@ -1103,7 +1103,7 @@ other process owned by the same user (or effective user). But only a
|
||||
privileged process can lower its nice value. A privileged process can
|
||||
also raise or lower another process' nice value.
|
||||
|
||||
GNU C Library functions for getting and setting nice values are described in
|
||||
GNU C Library functions for getting and setting nice values are described in
|
||||
@xref{Traditional Scheduling Functions}.
|
||||
|
||||
@node Traditional Scheduling Functions
|
||||
@ -1241,4 +1241,3 @@ nice (int increment)
|
||||
@}
|
||||
@end smallexample
|
||||
@end deftypefun
|
||||
|
||||
|
@ -1064,6 +1064,35 @@ object beginning at @var{block}. The return value is a pointer to the
|
||||
located byte, or a null pointer if no match was found.
|
||||
@end deftypefun
|
||||
|
||||
@comment string.h
|
||||
@comment GNU
|
||||
@deftypefun {void *} rawmemchr (const void *@var{block}, int @var{c})
|
||||
Often the @code{memchr} function is used with the knowledge that the
|
||||
byte @var{c} is available in the memory block specified by the
|
||||
parameters. But this means that the @var{size} parameter is not really
|
||||
needed and that the tests performed with it at runtime (to check whether
|
||||
the end of the block is reached) are not needed.
|
||||
|
||||
The @code{rawmemchr} function exists for just this situation which is
|
||||
surprisingly frequent. The interface is similar to @code{memchr} except
|
||||
that the @var{size} parameter is missing. The function will look beyond
|
||||
the end of the block pointed to by @var{block} in case the programmer
|
||||
made in error in assuming that the byte @var{c} is present in the block.
|
||||
In this case the result is unspecified. Otherwise the return value is a
|
||||
pointer to the located byte.
|
||||
|
||||
This function is of special interest when looking for the end of a
|
||||
string. Since all strings are terminated by a null byte a call like
|
||||
|
||||
@smallexample
|
||||
rawmemchr (str, '\0')
|
||||
@end smallexample
|
||||
|
||||
will never go beyond the end of the string.
|
||||
|
||||
This function is a GNU extension.
|
||||
@end deftypefun
|
||||
|
||||
@comment string.h
|
||||
@comment GNU
|
||||
@deftypefun {void *} memrchr (const void *@var{block}, int @var{c}, size_t @var{size})
|
||||
@ -1094,7 +1123,7 @@ specifying a null character as the value of the @var{c} argument.
|
||||
@end deftypefun
|
||||
|
||||
@comment string.h
|
||||
@comment ???
|
||||
@comment GNU
|
||||
@deftypefun {char *} strchrnul (const char *@var{string}, int @var{c})
|
||||
@code{strchrnul} is the same as @code{strchr} except that if it does
|
||||
not find the character, it returns a pointer to string's terminating
|
||||
|
@ -159,7 +159,7 @@ The specifics of this function are analogous to @code{gethostname}, above.
|
||||
|
||||
@comment unistd.h
|
||||
@comment ???
|
||||
@deftypefun int setdomainnname (const char *@var{name}, size_t @var{length})
|
||||
@deftypefun int setdomainname (const char *@var{name}, size_t @var{length})
|
||||
@cindex NIS domain name
|
||||
@cindex YP domain name
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991,92,93,95,96,97,1998,2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -18,22 +18,23 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
/* Time the program started. */
|
||||
extern time_t _posix_start_time;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static clock_t
|
||||
timeval_to_clock_t (const struct timeval *tv)
|
||||
timeval_to_clock_t (const struct timeval *tv, clock_t clk_tck)
|
||||
{
|
||||
return (clock_t) ((tv->tv_sec * CLK_TCK) +
|
||||
(tv->tv_usec * CLK_TCK / 1000000L));
|
||||
return (clock_t) ((tv->tv_sec * clk_tck) +
|
||||
(tv->tv_usec * clk_tck / 1000000L));
|
||||
}
|
||||
|
||||
/* Store the CPU time used by this process and all its
|
||||
@ -45,6 +46,7 @@ __times (buffer)
|
||||
struct tms *buffer;
|
||||
{
|
||||
struct rusage usage;
|
||||
clock_t clk_tck;
|
||||
|
||||
if (buffer == NULL)
|
||||
{
|
||||
@ -52,17 +54,19 @@ __times (buffer)
|
||||
return (clock_t) -1;
|
||||
}
|
||||
|
||||
clk_tck = __getclktck ();
|
||||
|
||||
if (__getrusage (RUSAGE_SELF, &usage) < 0)
|
||||
return (clock_t) -1;
|
||||
buffer->tms_utime = (clock_t) timeval_to_clock_t (&usage.ru_utime);
|
||||
buffer->tms_stime = (clock_t) timeval_to_clock_t (&usage.ru_stime);
|
||||
buffer->tms_utime = (clock_t) timeval_to_clock_t (&usage.ru_utime, clk_tck);
|
||||
buffer->tms_stime = (clock_t) timeval_to_clock_t (&usage.ru_stime, clk_tck);
|
||||
|
||||
if (__getrusage (RUSAGE_CHILDREN, &usage) < 0)
|
||||
return (clock_t) -1;
|
||||
buffer->tms_cutime = (clock_t) timeval_to_clock_t (&usage.ru_utime);
|
||||
buffer->tms_cstime = (clock_t) timeval_to_clock_t (&usage.ru_stime);
|
||||
buffer->tms_cutime = (clock_t) timeval_to_clock_t (&usage.ru_utime, clk_tck);
|
||||
buffer->tms_cstime = (clock_t) timeval_to_clock_t (&usage.ru_stime, clk_tck);
|
||||
|
||||
return (time ((time_t *) NULL) - _posix_start_time) * CLK_TCK;
|
||||
return (time ((time_t *) NULL) - _posix_start_time) * clk_tck;
|
||||
}
|
||||
|
||||
weak_alias (__times, times)
|
||||
|
Loading…
Reference in New Issue
Block a user