Decode RUSAGE_THREAD
* xlat/usagewho.in: Add values for existing entities, add RUSAGE_THREAD. * tests/getrusage.c: Test decoding of RUSAGE_THREAD.
This commit is contained in:
parent
b24254d34c
commit
9407d10e12
@ -35,18 +35,23 @@
|
||||
# include <stdint.h>
|
||||
# include <sys/resource.h>
|
||||
# include <unistd.h>
|
||||
# include <errno.h>
|
||||
|
||||
# include "xlat.h"
|
||||
# include "xlat/usagewho.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
invoke_print(int who, const char *who_str, struct rusage *usage)
|
||||
{
|
||||
struct rusage *const usage = tail_alloc(sizeof(struct rusage));
|
||||
int rc = syscall(__NR_getrusage, RUSAGE_SELF, usage);
|
||||
printf("getrusage(RUSAGE_SELF, {ru_utime={tv_sec=%jd, tv_usec=%jd}"
|
||||
int rc = syscall(__NR_getrusage, who, usage);
|
||||
int saved_errno = errno;
|
||||
printf("getrusage(%s, {ru_utime={tv_sec=%jd, tv_usec=%jd}"
|
||||
", ru_stime={tv_sec=%jd, tv_usec=%jd}, ru_maxrss=%lu"
|
||||
", ru_ixrss=%lu, ru_idrss=%lu, ru_isrss=%lu, ru_minflt=%lu"
|
||||
", ru_majflt=%lu, ru_nswap=%lu, ru_inblock=%lu"
|
||||
", ru_oublock=%lu, ru_msgsnd=%lu, ru_msgrcv=%lu"
|
||||
", ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}) = %d\n",
|
||||
", ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}) = %s\n",
|
||||
who_str,
|
||||
(intmax_t) usage->ru_utime.tv_sec,
|
||||
(intmax_t) usage->ru_utime.tv_usec,
|
||||
(intmax_t) usage->ru_stime.tv_sec,
|
||||
@ -55,7 +60,21 @@ main(void)
|
||||
usage->ru_isrss, usage->ru_minflt, usage->ru_majflt,
|
||||
usage->ru_nswap, usage->ru_inblock, usage->ru_oublock,
|
||||
usage->ru_msgsnd, usage->ru_msgrcv, usage->ru_nsignals,
|
||||
usage->ru_nvcsw, usage->ru_nivcsw, rc);
|
||||
usage->ru_nvcsw, usage->ru_nivcsw, sprintrc(rc));
|
||||
errno = saved_errno;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
struct rusage *const usage = tail_alloc(sizeof(*usage));
|
||||
if (invoke_print(ARG_STR(RUSAGE_SELF), usage)) {
|
||||
perror_msg_and_fail("RUSAGE_SELF");
|
||||
}
|
||||
if (invoke_print(ARG_STR(RUSAGE_THREAD), usage) && errno != EINVAL) {
|
||||
perror_msg_and_fail("RUSAGE_THREAD");
|
||||
}
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
return 0;
|
||||
|
@ -1,3 +1,4 @@
|
||||
RUSAGE_SELF
|
||||
RUSAGE_CHILDREN
|
||||
RUSAGE_BOTH
|
||||
RUSAGE_SELF 0
|
||||
RUSAGE_CHILDREN (-1)
|
||||
RUSAGE_BOTH (-2)
|
||||
RUSAGE_THREAD 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user