From c641c2b9ee04fdd1ef8bd2bef473c319d0f83401 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 8 Apr 1998 09:01:53 +0000 Subject: [PATCH] Minor adjustments to the timecounting and proc0. Mostly Submitted by: bde --- sys/kern/init_main.c | 12 +++++++----- sys/kern/kern_clock.c | 6 +++--- sys/kern/kern_tc.c | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index e9f061024d94..572eff1de04e 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -39,7 +39,7 @@ * SUCH DAMAGE. * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 - * $Id: init_main.c,v 1.86 1998/04/04 13:25:08 phk Exp $ + * $Id: init_main.c,v 1.87 1998/04/06 15:51:22 peter Exp $ */ #include "opt_devfs.h" @@ -422,19 +422,21 @@ static void proc0_post(dummy) void *dummy; { - struct timeval tv; struct timespec ts; /* * Now can look at time, having had a chance to verify the time * from the file system. Reset p->p_rtime as it may have been - * munched in mi_switch() after the time got set. + * munched in mi_switch() after the time got set. Set + * p->p_runtime to be consistent with this unmunching. */ - proc0.p_stats->p_start = boottime; - proc0.p_rtime.tv_sec = proc0.p_rtime.tv_usec = 0; + microtime(&proc0.p_stats->p_start); + timevalclear(&proc0.p_rtime); + microruntime(&proc0.p_runtime); /* * Give the ``random'' number generator a thump. + * XXX: Does read_random() contain enough bits to be used here ? */ nanotime(&ts); srandom(ts.tv_sec ^ ts.tv_nsec); diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 13195c3cd869..a70ab9dbe534 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -39,7 +39,7 @@ static volatile int print_tci = 1; * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.65 1998/04/05 11:49:34 phk Exp $ + * $Id: kern_clock.c,v 1.66 1998/04/06 08:26:03 phk Exp $ */ #include @@ -756,7 +756,7 @@ tco_forward(void) timedelta -= tickdelta; } - if (tc->offset_nano >= 1000000000ULL << 32) { + while (tc->offset_nano >= 1000000000ULL << 32) { tc->offset_nano -= 1000000000ULL << 32; tc->offset_sec++; tc->frequency = tc->tweak->frequency; @@ -771,7 +771,7 @@ tco_forward(void) tc->nanotime.tv_sec = tc->offset_sec + boottime.tv_sec; tc->nanotime.tv_nsec = (tc->offset_nano >> 32) + boottime.tv_usec * 1000; tc->microtime.tv_usec = tc->offset_micro + boottime.tv_usec; - if (tc->nanotime.tv_nsec > 1000000000) { + if (tc->nanotime.tv_nsec >= 1000000000) { tc->nanotime.tv_nsec -= 1000000000; tc->microtime.tv_usec -= 1000000; tc->nanotime.tv_sec++; diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 13195c3cd869..a70ab9dbe534 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -39,7 +39,7 @@ static volatile int print_tci = 1; * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.65 1998/04/05 11:49:34 phk Exp $ + * $Id: kern_clock.c,v 1.66 1998/04/06 08:26:03 phk Exp $ */ #include @@ -756,7 +756,7 @@ tco_forward(void) timedelta -= tickdelta; } - if (tc->offset_nano >= 1000000000ULL << 32) { + while (tc->offset_nano >= 1000000000ULL << 32) { tc->offset_nano -= 1000000000ULL << 32; tc->offset_sec++; tc->frequency = tc->tweak->frequency; @@ -771,7 +771,7 @@ tco_forward(void) tc->nanotime.tv_sec = tc->offset_sec + boottime.tv_sec; tc->nanotime.tv_nsec = (tc->offset_nano >> 32) + boottime.tv_usec * 1000; tc->microtime.tv_usec = tc->offset_micro + boottime.tv_usec; - if (tc->nanotime.tv_nsec > 1000000000) { + if (tc->nanotime.tv_nsec >= 1000000000) { tc->nanotime.tv_nsec -= 1000000000; tc->microtime.tv_usec -= 1000000; tc->nanotime.tv_sec++;