MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sched_pctcpu_delta

Function sched_pctcpu_delta

freebsd/kern/sched_4bsd.c:1599–1625  ·  view source on GitHub ↗

* Calculates the contribution to the thread cpu usage for the latest * (unfinished) second. */

Source from the content-addressed store, hash-verified

1597 * (unfinished) second.
1598 */
1599fixpt_t
1600sched_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
1628u_int

Callers 1

racct_getpcpuFunction · 0.85

Calls 1

td_get_schedFunction · 0.85

Tested by

no test coverage detected