MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tdq_move

Function tdq_move

freebsd/kern/sched_ule.c:949–977  ·  view source on GitHub ↗

* Move a thread from one thread queue to another. */

Source from the content-addressed store, hash-verified

947 * Move a thread from one thread queue to another.
948 */
949static struct thread *
950tdq_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

Callers 3

sched_balance_pairFunction · 0.85
tdq_idledFunction · 0.85
tdq_trystealFunction · 0.85

Calls 5

tdq_stealFunction · 0.85
thread_lock_block_waitFunction · 0.85
td_get_schedFunction · 0.85
tdq_addFunction · 0.85
sched_remFunction · 0.70

Tested by

no test coverage detected