Improve the accuracy of the POSIX "process CPU-time" clocks by adding the
authorcperciva <cperciva@FreeBSD.org>
Fri, 22 Jun 2018 10:23:32 +0000 (10:23 +0000)
committercperciva <cperciva@FreeBSD.org>
Fri, 22 Jun 2018 10:23:32 +0000 (10:23 +0000)
commitcd7d3540907df80d3de47680b723a06e37d75825
tree765e7b9a16ee8b16b8b033d75ae240d1a9caebc6
parent825b24c8a7c170c5de0199567b9ded3a4e8c4873
Improve the accuracy of the POSIX "process CPU-time" clocks by adding the
used portion of the current thread's time slice if the current thread
belongs to the process being queried (i.e., if clock_gettime is invoked
with a clock ID of CLOCK_PROCESS_CPUTIME_ID or the value provided by
passing getpid(2) to clock_getcpuclockid(3)).

The CLOCK_VIRTUAL and CLOCK_PROF timers already make this adjustment via
long-standing code in calcru(), but since those timers are not specified
by POSIX it seems useful to add it here so that the higher accuracy is
available to code which aims to be portable.

PR: 228669
Reported by: Graham Percival
Reviewed by: kib
MFC after: 1 week
sys/kern/kern_time.c