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

Function sched_pctcpu_update

freebsd/kern/sched_ule.c:1721–1741  ·  view source on GitHub ↗

* Update the percent cpu tracking information when it is requested or * the total history exceeds the maximum. We keep a sliding history of * tick counts that slowly decays. This is less precise than the 4BSD * mechanism since it happens with less regular and frequent events. */

Source from the content-addressed store, hash-verified

1719 * mechanism since it happens with less regular and frequent events.
1720 */
1721static void
1722sched_pctcpu_update(struct td_sched *ts, int run)
1723{
1724 int t = ticks;
1725
1726 /*
1727 * The signed difference may be negative if the thread hasn't run for
1728 * over half of the ticks rollover period.
1729 */
1730 if ((u_int)(t - ts->ts_ltick) >= SCHED_TICK_TARG) {
1731 ts->ts_ticks = 0;
1732 ts->ts_ftick = t - SCHED_TICK_TARG;
1733 } else if (t - ts->ts_ftick >= SCHED_TICK_MAX) {
1734 ts->ts_ticks = (ts->ts_ticks / (ts->ts_ltick - ts->ts_ftick)) *
1735 (ts->ts_ltick - (t - SCHED_TICK_TARG));
1736 ts->ts_ftick = t - SCHED_TICK_TARG;
1737 }
1738 if (run)
1739 ts->ts_ticks += (t - ts->ts_ltick) << SCHED_TICK_SHIFT;
1740 ts->ts_ltick = t;
1741}
1742
1743/*
1744 * Adjust the priority of a thread. Move it to the appropriate run-queue

Callers 5

sched_switchFunction · 0.85
sched_wakeupFunction · 0.85
sched_forkFunction · 0.85
sched_clockFunction · 0.85
sched_pctcpuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected