diff options
author | phk <phk@FreeBSD.org> | 1999-11-29 11:29:04 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-11-29 11:29:04 +0000 |
commit | 8da3ba86dcb25f842958179693b5d802d91ae681 (patch) | |
tree | 4868f81c1c195acf2e065944af8bede54779fd0c /sys/kern/kern_synch.c | |
parent | d1d5bef80771c347e974ca1f996e28808a4077a7 (diff) | |
download | FreeBSD-src-8da3ba86dcb25f842958179693b5d802d91ae681.zip FreeBSD-src-8da3ba86dcb25f842958179693b5d802d91ae681.tar.gz |
Add a bit of sanity checking and problem avoidance in case the
timecounter hardware is bogus.
This will produce a new warning "microuptime() went backwards"
and try to not screw up the process resource accounting.
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r-- | sys/kern/kern_synch.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 597f5e6..16699e0 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -791,8 +791,15 @@ mi_switch() * process was running, and add that to its total so far. */ microuptime(&new_switchtime); - p->p_runtime += (new_switchtime.tv_usec - switchtime.tv_usec) + - (new_switchtime.tv_sec - switchtime.tv_sec) * (int64_t)1000000; + if (timevalcmp(&new_switchtime, &switchtime, <)) { + printf("microuptime() went backwards (%ld.%06ld -> %ld,%06ld)\n", + switchtime.tv_sec, switchtime.tv_usec, + new_switchtime.tv_sec, new_switchtime.tv_usec); + new_switchtime = switchtime; + } else { + p->p_runtime += (new_switchtime.tv_usec - switchtime.tv_usec) + + (new_switchtime.tv_sec - switchtime.tv_sec) * (int64_t)1000000; + } /* * Check if the process exceeds its cpu resource allocation. |