| 248 | } |
| 249 | |
| 250 | void |
| 251 | kern_thread_cputime(struct thread *targettd, struct timespec *ats) |
| 252 | { |
| 253 | uint64_t runtime, curtime, switchtime; |
| 254 | |
| 255 | if (targettd == NULL) { /* current thread */ |
| 256 | critical_enter(); |
| 257 | switchtime = PCPU_GET(switchtime); |
| 258 | curtime = cpu_ticks(); |
| 259 | runtime = curthread->td_runtime; |
| 260 | critical_exit(); |
| 261 | runtime += curtime - switchtime; |
| 262 | } else { |
| 263 | PROC_LOCK_ASSERT(targettd->td_proc, MA_OWNED); |
| 264 | thread_lock(targettd); |
| 265 | runtime = targettd->td_runtime; |
| 266 | thread_unlock(targettd); |
| 267 | } |
| 268 | cputick2timespec(runtime, ats); |
| 269 | } |
| 270 | |
| 271 | void |
| 272 | kern_process_cputime(struct proc *targetp, struct timespec *ats) |
no test coverage detected