Make sure reading td_runtime in critical section since thread may be

preempted and td_runtime will be modified.
This commit is contained in:
David Xu 2008-01-18 13:00:28 +00:00
parent 1e8f5ffa35
commit 0e17ccbe36
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=175439

View File

@ -247,8 +247,9 @@ kern_clock_gettime(struct thread *td, clockid_t clock_id, struct timespec *ats)
critical_enter();
switchtime = PCPU_GET(switchtime);
curtime = cpu_ticks();
runtime = td->td_runtime;
critical_exit();
runtime = cputick2usec(td->td_runtime + curtime - switchtime);
runtime = cputick2usec(runtime + curtime - switchtime);
ats->tv_sec = runtime / 1000000;
ats->tv_nsec = runtime % 1000000 * 1000;
break;