FreeBSD/sys/kern/sched_ule.c
/*
 * Steals load from a standard linear queue.
 */
Steals load from a standard linear queue.
Steals load from a standard linear queue .
static struct thread *
runq_steal(struct runq *rq, int cpu)
{
	struct rqhead *rqh;
	struct rqbits *rqb;
	struct thread *td;
	int word;
	int bit;
	rqb = &rq->rq_status;
	for (word = 0; word < RQB_LEN; word++) {
		if (rqb->rqb_bits[word] == 0)
			continue;
		for (bit = 0; bit < RQB_BPW; bit++) {
			if ((rqb->rqb_bits[word] & (1ul << bit)) == 0)
				continue;
			rqh = &rq->rq_queues[bit + (word << RQB_L2BPW)];
			TAILQ_FOREACH(td, rqh, td_runq)
				if (THREAD_CAN_MIGRATE(td) &&
				    THREAD_CAN_SCHED(td, cpu))
					return (td);
		}
	}
	return (NULL);
}
static struct thread * runq_steal ( struct runq * rq , int cpu ) { struct rqhead * rqh ; struct rqbits * rqb ; struct thread * td ; int word ; int bit ; rqb = & rq -> rq_status ; for ( word = 0 ; word < RQB_LEN ; word ++ ) { if ( rqb -> rqb_bits [ word ] == 0 ) continue ; for ( bit = 0 ; bit < RQB_BPW ; bit ++ ) { if ( ( rqb -> rqb_bits [ word ] & ( 1ul << bit ) ) == 0 ) continue ; rqh = & rq -> rq_queues [ bit + ( word << RQB_L2BPW ) ] ; TAILQ_FOREACH ( td , rqh , td_runq ) if ( THREAD_CAN_MIGRATE ( td ) && THREAD_CAN_SCHED ( td , cpu ) ) return ( td ) ; } } return ( NULL ) ; }
Steals load from a standard linear queue.
Steals load from a standard linear queue .