* 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. */
| 1719 | * mechanism since it happens with less regular and frequent events. |
| 1720 | */ |
| 1721 | static void |
| 1722 | sched_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 |
no outgoing calls
no test coverage detected