* Calculates the contribution to the thread cpu usage for the latest * (unfinished) second. */
| 1597 | * (unfinished) second. |
| 1598 | */ |
| 1599 | fixpt_t |
| 1600 | sched_pctcpu_delta(struct thread *td) |
| 1601 | { |
| 1602 | struct td_sched *ts; |
| 1603 | fixpt_t delta; |
| 1604 | int realstathz; |
| 1605 | |
| 1606 | THREAD_LOCK_ASSERT(td, MA_OWNED); |
| 1607 | ts = td_get_sched(td); |
| 1608 | delta = 0; |
| 1609 | realstathz = stathz ? stathz : hz; |
| 1610 | if (ts->ts_cpticks != 0) { |
| 1611 | #if (FSHIFT >= CCPU_SHIFT) |
| 1612 | delta = (realstathz == 100) |
| 1613 | ? ((fixpt_t) ts->ts_cpticks) << |
| 1614 | (FSHIFT - CCPU_SHIFT) : |
| 1615 | 100 * (((fixpt_t) ts->ts_cpticks) |
| 1616 | << (FSHIFT - CCPU_SHIFT)) / realstathz; |
| 1617 | #else |
| 1618 | delta = ((FSCALE - ccpu) * |
| 1619 | (ts->ts_cpticks * |
| 1620 | FSCALE / realstathz)) >> FSHIFT; |
| 1621 | #endif |
| 1622 | } |
| 1623 | |
| 1624 | return (delta); |
| 1625 | } |
| 1626 | #endif |
| 1627 | |
| 1628 | u_int |
no test coverage detected