1139825Simp/*-
272376Sjake * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
372376Sjake * All rights reserved.
472376Sjake *
572376Sjake * Redistribution and use in source and binary forms, with or without
672376Sjake * modification, are permitted provided that the following conditions
772376Sjake * are met:
872376Sjake * 1. Redistributions of source code must retain the above copyright
972376Sjake *    notice, this list of conditions and the following disclaimer.
1072376Sjake * 2. Redistributions in binary form must reproduce the above copyright
1172376Sjake *    notice, this list of conditions and the following disclaimer in the
1272376Sjake *    documentation and/or other materials provided with the distribution.
1372376Sjake *
1472376Sjake * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1572376Sjake * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1672376Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1772376Sjake * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1872376Sjake * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1972376Sjake * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2072376Sjake * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2172376Sjake * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2272376Sjake * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2372376Sjake * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2472376Sjake * SUCH DAMAGE.
2572376Sjake *
2672376Sjake * $FreeBSD$
2772376Sjake */
2872376Sjake
2972376Sjake#ifndef	_RUNQ_H_
3072376Sjake#define	_RUNQ_H_
3172376Sjake
3297261Sjake#include <machine/runq.h>
3397261Sjake
34177435Sjeffstruct thread;
3583366Sjulian
3672376Sjake/*
3772376Sjake * Run queue parameters.
3872376Sjake */
3972376Sjake
4072376Sjake#define	RQ_NQS		(64)		/* Number of run queues. */
4172376Sjake#define	RQ_PPQ		(4)		/* Priorities per queue. */
4272376Sjake
4372376Sjake/*
4472376Sjake * Head of run queues.
4572376Sjake */
46177435SjeffTAILQ_HEAD(rqhead, thread);
4772376Sjake
4872376Sjake/*
4972376Sjake * Bit array which maintains the status of a run queue.  When a queue is
5072376Sjake * non-empty the bit corresponding to the queue number will be set.
5172376Sjake */
5283045Sobrienstruct rqbits {
5372376Sjake	rqb_word_t rqb_bits[RQB_LEN];
5472376Sjake};
5572376Sjake
5672376Sjake/*
5772376Sjake * Run queue structure.  Contains an array of run queues on which processes
5872376Sjake * are placed, and a structure to maintain the status of each queue.
5972376Sjake */
6083045Sobrienstruct runq {
6172376Sjake	struct	rqbits rq_status;
6272376Sjake	struct	rqhead rq_queues[RQ_NQS];
6372376Sjake};
6472376Sjake
65177435Sjeffvoid	runq_add(struct runq *, struct thread *, int);
66177435Sjeffvoid	runq_add_pri(struct runq *, struct thread *, u_char, int);
6772376Sjakeint	runq_check(struct runq *);
68177435Sjeffstruct	thread *runq_choose(struct runq *);
69177435Sjeffstruct	thread *runq_choose_from(struct runq *, u_char);
70177435Sjeffstruct	thread *runq_choose_fuzz(struct runq *, int);
7172376Sjakevoid	runq_init(struct runq *);
72177435Sjeffvoid	runq_remove(struct runq *, struct thread *);
73177435Sjeffvoid	runq_remove_idx(struct runq *, struct thread *, u_char *);
7472376Sjake
7572376Sjake#endif
76