* Move a thread from one thread queue to another. */
| 947 | * Move a thread from one thread queue to another. |
| 948 | */ |
| 949 | static struct thread * |
| 950 | tdq_move(struct tdq *from, struct tdq *to) |
| 951 | { |
| 952 | struct thread *td; |
| 953 | struct tdq *tdq; |
| 954 | int cpu; |
| 955 | |
| 956 | TDQ_LOCK_ASSERT(from, MA_OWNED); |
| 957 | TDQ_LOCK_ASSERT(to, MA_OWNED); |
| 958 | |
| 959 | tdq = from; |
| 960 | cpu = TDQ_ID(to); |
| 961 | td = tdq_steal(tdq, cpu); |
| 962 | if (td == NULL) |
| 963 | return (NULL); |
| 964 | |
| 965 | /* |
| 966 | * Although the run queue is locked the thread may be |
| 967 | * blocked. We can not set the lock until it is unblocked. |
| 968 | */ |
| 969 | thread_lock_block_wait(td); |
| 970 | sched_rem(td); |
| 971 | THREAD_LOCKPTR_ASSERT(td, TDQ_LOCKPTR(from)); |
| 972 | td->td_lock = TDQ_LOCKPTR(to); |
| 973 | td_get_sched(td)->ts_cpu = cpu; |
| 974 | tdq_add(to, td, SRQ_YIELDING); |
| 975 | |
| 976 | return (td); |
| 977 | } |
| 978 | |
| 979 | /* |
| 980 | * This tdq has idled. Try to steal a thread from another cpu and switch |
no test coverage detected