Get accounting data of given task. * * Note that task lock of 'task' must be already held and interrupts must be * already disabled. * * @param task Pointer to the task. * @param ucycles Out pointer to sum of all user cycles. * @param kcycles Out pointer to sum of all kernel cycles. * */
| 495 | * |
| 496 | */ |
| 497 | void task_get_accounting(task_t *task, uint64_t *ucycles, uint64_t *kcycles) |
| 498 | { |
| 499 | assert(interrupts_disabled()); |
| 500 | assert(irq_spinlock_locked(&task->lock)); |
| 501 | |
| 502 | /* Accumulated values of task */ |
| 503 | uint64_t uret = task->ucycles; |
| 504 | uint64_t kret = task->kcycles; |
| 505 | |
| 506 | /* Current values of threads */ |
| 507 | list_foreach(task->threads, th_link, thread_t, thread) { |
| 508 | irq_spinlock_lock(&thread->lock, false); |
| 509 | |
| 510 | /* Process only counted threads */ |
| 511 | if (!thread->uncounted) { |
| 512 | if (thread == THREAD) { |
| 513 | /* Update accounting of current thread */ |
| 514 | thread_update_accounting(false); |
| 515 | } |
| 516 | |
| 517 | uret += thread->ucycles; |
| 518 | kret += thread->kcycles; |
| 519 | } |
| 520 | |
| 521 | irq_spinlock_unlock(&thread->lock, false); |
| 522 | } |
| 523 | |
| 524 | *ucycles = uret; |
| 525 | *kcycles = kret; |
| 526 | } |
| 527 | |
| 528 | static void task_kill_internal(task_t *task) |
| 529 | { |
no test coverage detected