Lines 250-264
Link Here
|
250 |
|
250 |
|
251 |
void |
251 |
void |
252 |
kern_thread_cputime(struct thread *targettd, struct timespec *ats) |
252 |
kern_thread_cputime(struct thread *targettd, struct timespec *ats) |
253 |
{ |
253 |
{ |
254 |
uint64_t runtime, curtime, switchtime; |
254 |
uint64_t runtime, curtime, switchtime, switchtime_check; |
255 |
|
255 |
|
256 |
if (targettd == NULL) { /* current thread */ |
256 |
if (targettd == NULL) { /* current thread */ |
257 |
critical_enter(); |
257 |
do { |
258 |
switchtime = PCPU_GET(switchtime); |
258 |
critical_enter(); |
259 |
curtime = cpu_ticks(); |
259 |
switchtime = PCPU_GET(switchtime); |
260 |
runtime = curthread->td_runtime; |
260 |
curtime = cpu_ticks(); |
261 |
critical_exit(); |
261 |
runtime = curthread->td_runtime; |
|
|
262 |
switchtime_check = PCPU_GET(switchtime); |
263 |
critical_exit(); |
264 |
} while (switchtime != switchtime_check); |
262 |
runtime += curtime - switchtime; |
265 |
runtime += curtime - switchtime; |
263 |
} else { |
266 |
} else { |
264 |
PROC_LOCK_ASSERT(targettd->td_proc, MA_OWNED); |
267 |
PROC_LOCK_ASSERT(targettd->td_proc, MA_OWNED); |