* Fetch cpu utilization information. Updates on demand. */
| 2653 | * Fetch cpu utilization information. Updates on demand. |
| 2654 | */ |
| 2655 | fixpt_t |
| 2656 | sched_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 |
no test coverage detected