From 3db15a3f80f193826e144b1944727a65c13340fe Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 25 Jul 2015 18:23:10 +0200 Subject: kern: add boot-time clock, use it for time stamps The kernel keeps track of task and thread creation times by saving a time stamp. Previously, the real-time clock was used for this. When the real-time clock is changed, however, the reference frame for the time stamps is lost. This surfaced in Hurd systems reporting spuriously long uptimes. Fix this by creating a boot-time clock and use it as reference frame for the time stamps. * kern/mach_clock.c (clock_boottime_offset): Create clock by keeping track of the offset from the real-time. (clock_boottime_update): New function. (record_time_stamp): Use the boot-time clock for time stamps. (read_time_stamp): New function to convert it back to real-time. (host_set_time): Call `clock_boottime_update'. * kern/mach_clock.h (record_time_stamp): Amend comment. (read_time_stamp): New declaration. * kern/task.c (task_info): Use `read_time_stamp'. * kern/thread.c (thread_info): Likewise. --- kern/mach_clock.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'kern/mach_clock.h') diff --git a/kern/mach_clock.h b/kern/mach_clock.h index 89fd335..1af0cda 100644 --- a/kern/mach_clock.h +++ b/kern/mach_clock.h @@ -86,9 +86,18 @@ extern boolean_t reset_timeout(timer_elt_t telt); extern void init_timeout (void); -/* Read the current time into STAMP. */ +/* + * Record a timestamp in STAMP. Records values in the boot-time clock + * frame. + */ extern void record_time_stamp (time_value_t *stamp); +/* + * Read a timestamp in STAMP into RESULT. Returns values in the + * real-time clock frame. + */ +extern void read_time_stamp (time_value_t *stamp, time_value_t *result); + extern kern_return_t host_get_time( host_t host, time_value_t *current_time); -- cgit v1.2.3