FreeBSD/sys/netpfil/ipfw/dn_sched_prio.c
/*
 * Packets are dequeued only from the highest priority queue.
 * The function ffs() return the lowest bit in the bitmap that rapresent
 * the array index (-1) which contains the pointer to the highest priority
 * queue.
 * After the dequeue, if this queue become empty, it is index is removed
 * from the bitmap.
 * Scheduler is idle if the bitmap is empty
 *
 * NOTE: highest priority is 0, lowest is sched->max_prio_q
 */
Packets are dequeued only from the highest priority queue.
The function ffs() return the lowest bit in the bitmap that rapresent
the array index (-1) which contains the pointer to the highest priority
queue.
After the dequeue, if this queue become empty, it is index is removed
from the bitmap.
Scheduler is idle if the bitmap is empty

highest priority is 0, lowest is sched->max_prio_q
Packets are dequeued only from the highest priority queue . The function ffs () return the lowest bit in the bitmap that rapresent the array index ( - 1 ) which contains the pointer to the highest priority queue . After the dequeue if this queue become empty it is index is removed from the bitmap . Scheduler is idle if the bitmap is empty highest priority is 0 lowest is sched - > max_prio_q
static struct mbuf *
prio_dequeue(struct dn_sch_inst *_si)
{
	struct prio_si *si = (struct prio_si *)(_si + 1);
	struct mbuf *m;
	struct dn_queue *q;
	int prio;
	if (si->bitmap == 0) 
		return NULL;
	prio = ffs(si->bitmap) - 1;
	q = si->q_array[prio];
	m = dn_dequeue(q);
	if (q->mq.head == NULL) {
		si->q_array[prio] = NULL;
		__clear_bit(prio, &si->bitmap);
	}
	return m;
}
static struct mbuf * prio_dequeue ( struct dn_sch_inst * _si ) { struct prio_si * si = ( struct prio_si * ) ( _si + 1 ) ; struct mbuf * m ; struct dn_queue * q ; int prio ; if ( si -> bitmap == 0 ) return NULL ; prio = ffs ( si -> bitmap ) - 1 ; q = si -> q_array [ prio ] ; m = dn_dequeue ( q ) ; if ( q -> mq . head == NULL ) { si -> q_array [ prio ] = NULL ; __clear_bit ( prio , & si -> bitmap ) ; } return m ; }
Packets are dequeued only from the highest priority queue.
Packets are dequeued only from the highest priority queue .
/* scheduler idle */ /* Take the highest priority queue in the scheduler */ // assert(q) /* Queue is now empty, remove from scheduler
		 * and mark it
		 */