priority.h revision 217075
1139825Simp/*-
272376Sjake * Copyright (c) 1994, Henrik Vestergaard Draboel
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 * 3. All advertising materials mentioning features or use of this software
1472376Sjake *    must display the following acknowledgement:
15165898Simp *	This product includes software developed by Henrik Vestergaard Draboel.
1672376Sjake * 4. The name of the author may not be used to endorse or promote products
1772376Sjake *    derived from this software without specific prior written permission.
1872376Sjake *
1972376Sjake * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2072376Sjake * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2172376Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2272376Sjake * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2372376Sjake * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2472376Sjake * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2572376Sjake * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2672376Sjake * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2772376Sjake * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2872376Sjake * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2972376Sjake * SUCH DAMAGE.
3072376Sjake *
3172376Sjake * $FreeBSD: head/sys/sys/priority.h 217075 2011-01-06 22:09:37Z jhb $
3272376Sjake */
3372376Sjake
3472376Sjake#ifndef _SYS_PRIORITY_H_
3572376Sjake#define _SYS_PRIORITY_H_
3672376Sjake
3772376Sjake/*
3872376Sjake * Process priority specifications.
3972376Sjake */
4072376Sjake
4172376Sjake/*
4272376Sjake * Priority classes.
4372376Sjake */
4472376Sjake
4572376Sjake#define	PRI_ITHD		1	/* Interrupt thread. */
4672376Sjake#define	PRI_REALTIME		2	/* Real time process. */
4772376Sjake#define	PRI_TIMESHARE		3	/* Time sharing process. */
4872376Sjake#define	PRI_IDLE		4	/* Idle process. */
4972376Sjake
5072376Sjake/*
5172376Sjake * PRI_FIFO is POSIX.1B SCHED_FIFO.
5272376Sjake */
5372376Sjake
5472376Sjake#define	PRI_FIFO_BIT		8
5572376Sjake#define	PRI_FIFO		(PRI_FIFO_BIT | PRI_REALTIME)
5672376Sjake
5772376Sjake#define	PRI_BASE(P)		((P) & ~PRI_FIFO_BIT)
5872376Sjake#define	PRI_IS_REALTIME(P)	(PRI_BASE(P) == PRI_REALTIME)
5972376Sjake#define	PRI_NEED_RR(P)		((P) != PRI_FIFO)
6072376Sjake
6172376Sjake/*
6272376Sjake * Priorities.  Note that with 64 run queues, differences less than 4 are
6372376Sjake * insignificant.
6472376Sjake */
6572376Sjake
6672376Sjake/*
6772376Sjake * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ)
6872376Sjake * are insignificant.  Ranges are as follows:
6972376Sjake *
7072376Sjake * Interrupt threads:		0 - 63
7172376Sjake * Top half kernel threads:	64 - 127
7272376Sjake * Realtime user threads:	128 - 159
7372376Sjake * Time sharing user threads:	160 - 223
7472376Sjake * Idle user threads:		224 - 255
7572376Sjake *
7672376Sjake * XXX If/When the specific interrupt thread and top half thread ranges
7772376Sjake * disappear, a larger range can be used for user processes.
7872376Sjake */
7972376Sjake
8072376Sjake#define	PRI_MIN			(0)		/* Highest priority. */
8172376Sjake#define	PRI_MAX			(255)		/* Lowest priority. */
8272376Sjake
8372376Sjake#define	PRI_MIN_ITHD		(PRI_MIN)
8472376Sjake#define	PRI_MAX_ITHD		(PRI_MIN_KERN - 1)
8572376Sjake
8672376Sjake#define	PI_REALTIME		(PRI_MIN_ITHD + 0)
8772376Sjake#define	PI_AV			(PRI_MIN_ITHD + 4)
8872376Sjake#define	PI_TTYHIGH		(PRI_MIN_ITHD + 8)
8972376Sjake#define	PI_TAPE			(PRI_MIN_ITHD + 12)
9072376Sjake#define	PI_NET			(PRI_MIN_ITHD + 16)
9172376Sjake#define	PI_DISK			(PRI_MIN_ITHD + 20)
9272376Sjake#define	PI_TTYLOW		(PRI_MIN_ITHD + 24)
9372376Sjake#define	PI_DISKLOW		(PRI_MIN_ITHD + 28)
9472376Sjake#define	PI_DULL			(PRI_MIN_ITHD + 32)
9572376Sjake#define	PI_SOFT			(PRI_MIN_ITHD + 36)
9672376Sjake
9772376Sjake#define	PRI_MIN_KERN		(64)
9872376Sjake#define	PRI_MAX_KERN		(PRI_MIN_REALTIME - 1)
9972376Sjake
10072376Sjake#define	PSWP			(PRI_MIN_KERN + 0)
10172376Sjake#define	PVM			(PRI_MIN_KERN + 4)
10272376Sjake#define	PINOD			(PRI_MIN_KERN + 8)
10372376Sjake#define	PRIBIO			(PRI_MIN_KERN + 12)
10472376Sjake#define	PVFS			(PRI_MIN_KERN + 16)
10572376Sjake#define	PZERO			(PRI_MIN_KERN + 20)
10672376Sjake#define	PSOCK			(PRI_MIN_KERN + 24)
10772376Sjake#define	PWAIT			(PRI_MIN_KERN + 28)
108217075Sjhb#define	PLOCK			(PRI_MIN_KERN + 32)
109217075Sjhb#define	PPAUSE			(PRI_MIN_KERN + 36)
11072376Sjake
11172376Sjake#define	PRI_MIN_REALTIME	(128)
11272376Sjake#define	PRI_MAX_REALTIME	(PRI_MIN_TIMESHARE - 1)
11372376Sjake
11472376Sjake#define	PRI_MIN_TIMESHARE	(160)
11572376Sjake#define	PRI_MAX_TIMESHARE	(PRI_MIN_IDLE - 1)
11672376Sjake
11772376Sjake#define	PUSER			(PRI_MIN_TIMESHARE)
11872376Sjake
11972376Sjake#define	PRI_MIN_IDLE		(224)
12072376Sjake#define	PRI_MAX_IDLE		(PRI_MAX)
12172376Sjake
12283045Sobrienstruct priority {
12372376Sjake	u_char	pri_class;	/* Scheduling class. */
12472376Sjake	u_char	pri_level;	/* Normal priority level. */
12572376Sjake	u_char	pri_native;	/* Priority before propogation. */
12672376Sjake	u_char	pri_user;	/* User priority based on p_cpu and p_nice. */
12772376Sjake};
12872376Sjake
12972376Sjake#endif	/* !_SYS_PRIORITY_H_ */
130