* Pick the highest priority task we have and return it. */
| 1374 | * Pick the highest priority task we have and return it. |
| 1375 | */ |
| 1376 | static struct thread * |
| 1377 | tdq_choose(struct tdq *tdq) |
| 1378 | { |
| 1379 | struct thread *td; |
| 1380 | |
| 1381 | TDQ_LOCK_ASSERT(tdq, MA_OWNED); |
| 1382 | td = runq_choose(&tdq->tdq_realtime); |
| 1383 | if (td != NULL) |
| 1384 | return (td); |
| 1385 | td = runq_choose_from(&tdq->tdq_timeshare, tdq->tdq_ridx); |
| 1386 | if (td != NULL) { |
| 1387 | KASSERT(td->td_priority >= PRI_MIN_BATCH, |
| 1388 | ("tdq_choose: Invalid priority on timeshare queue %d", |
| 1389 | td->td_priority)); |
| 1390 | return (td); |
| 1391 | } |
| 1392 | td = runq_choose(&tdq->tdq_idle); |
| 1393 | if (td != NULL) { |
| 1394 | KASSERT(td->td_priority >= PRI_MIN_IDLE, |
| 1395 | ("tdq_choose: Invalid priority on idle queue %d", |
| 1396 | td->td_priority)); |
| 1397 | return (td); |
| 1398 | } |
| 1399 | |
| 1400 | return (NULL); |
| 1401 | } |
| 1402 | |
| 1403 | /* |
| 1404 | * Initialize a thread queue. |
no test coverage detected