* Choose the highest priority thread to run. The thread is removed from * the run-queue while running however the load remains. For SMP we set * the tdq in the global idle bitmask if it idles here. */
| 2497 | * the tdq in the global idle bitmask if it idles here. |
| 2498 | */ |
| 2499 | struct thread * |
| 2500 | sched_choose(void) |
| 2501 | { |
| 2502 | struct thread *td; |
| 2503 | struct tdq *tdq; |
| 2504 | |
| 2505 | tdq = TDQ_SELF(); |
| 2506 | TDQ_LOCK_ASSERT(tdq, MA_OWNED); |
| 2507 | td = tdq_choose(tdq); |
| 2508 | if (td) { |
| 2509 | tdq_runq_rem(tdq, td); |
| 2510 | tdq->tdq_lowpri = td->td_priority; |
| 2511 | return (td); |
| 2512 | } |
| 2513 | tdq->tdq_lowpri = PRI_MAX_IDLE; |
| 2514 | return (PCPU_GET(idlethread)); |
| 2515 | } |
| 2516 | |
| 2517 | /* |
| 2518 | * Set owepreempt if necessary. Preemption never happens directly in ULE, |
no test coverage detected