Minor adjustments to the timecounting and proc0.

Mostly Submitted by:	bde
This commit is contained in:
Poul-Henning Kamp 1998-04-08 09:01:53 +00:00
parent b317bce843
commit 5f88ec3625
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=35099
3 changed files with 13 additions and 11 deletions

View File

@ -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);

View File

@ -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 <sys/param.h>
@ -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++;

View File

@ -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 <sys/param.h>
@ -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++;