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

Function sched_pctcpu

freebsd/kern/sched_ule.c:2655–2675  ·  view source on GitHub ↗

* Fetch cpu utilization information. Updates on demand. */

Source from the content-addressed store, hash-verified

2653 * Fetch cpu utilization information. Updates on demand.
2654 */
2655fixpt_t
2656sched_pctcpu(struct thread *td)
2657{
2658 fixpt_t pctcpu;
2659 struct td_sched *ts;
2660
2661 pctcpu = 0;
2662 ts = td_get_sched(td);
2663
2664 THREAD_LOCK_ASSERT(td, MA_OWNED);
2665 sched_pctcpu_update(ts, TD_IS_RUNNING(td));
2666 if (ts->ts_ticks) {
2667 int rtick;
2668
2669 /* How many rtick per second ? */
2670 rtick = min(SCHED_TICK_HZ(ts) / SCHED_TICK_SECS, hz);
2671 pctcpu = (FSCALE * ((FSCALE * rtick)/hz)) >> FSHIFT;
2672 }
2673
2674 return (pctcpu);
2675}
2676
2677/*
2678 * Enforce affinity settings for a thread. Called after adjustments to

Callers 6

fill_kinfo_aggregateFunction · 0.70
fill_kinfo_threadFunction · 0.70
racct_getpcpuFunction · 0.70
proc_sumFunction · 0.70
thread_compareFunction · 0.70
tty_infoFunction · 0.70

Calls 3

td_get_schedFunction · 0.85
sched_pctcpu_updateFunction · 0.85
minFunction · 0.85

Tested by

no test coverage detected