summaryrefslogtreecommitdiff
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorTor Egge <tegge@FreeBSD.org>2001-02-22 19:50:37 +0000
committerTor Egge <tegge@FreeBSD.org>2001-02-22 19:50:37 +0000
commit0d139b3741a76eec6fe405737f0820a966f56c34 (patch)
tree55db6bfb6b0dbadb25002f63b7fc2885096b3a06 /sys/kern/kern_resource.c
parente6c77250ef764b3e8c70f593671cd237d6061c3b (diff)
Notes
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 73ffb03db9f0..b872acd25819 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -567,19 +567,27 @@ calcru(p, up, sp, ip)
tu = p->p_runtime;
if (p == curproc) {
+ struct timeval old_switchtime;
/*
* Adjust for the current time slice. This is actually fairly
* important since the error here is on the order of a time
* quantum, which is much greater than the sampling error.
*/
- microuptime(&tv);
- if (timevalcmp(&tv, PCPU_PTR(switchtime), <))
+ do {
+ old_switchtime = PCPU_GET(switchtime);
+ microuptime(&tv);
+ } while (old_switchtime.tv_sec !=
+ PCPU_GET(switchtime.tv_sec) ||
+ old_switchtime.tv_usec !=
+ PCPU_GET(switchtime.tv_usec));
+ if (timevalcmp(&tv, &old_switchtime, <))
printf("microuptime() went backwards (%ld.%06ld -> %ld.%06ld)\n",
- PCPU_GET(switchtime.tv_sec), PCPU_GET(switchtime.tv_usec),
- tv.tv_sec, tv.tv_usec);
+ old_switchtime.tv_sec,
+ old_switchtime.tv_usec,
+ tv.tv_sec, tv.tv_usec);
else
- tu += (tv.tv_usec - PCPU_GET(switchtime.tv_usec)) +
- (tv.tv_sec - PCPU_GET(switchtime.tv_sec)) *
+ tu += (tv.tv_usec - old_switchtime.tv_usec) +
+ (tv.tv_sec - old_switchtime.tv_sec) *
(int64_t)1000000;
}
ptu = p->p_uu + p->p_su + p->p_iu;