1/*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (c) 1994, Henrik Vestergaard Draboel 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Henrik Vestergaard Draboel. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * $FreeBSD$ 34 */ 35 36#ifndef _SYS_PRIORITY_H_ 37#define _SYS_PRIORITY_H_ 38 39/* 40 * Process priority specifications. 41 */ 42 43/* 44 * Priority classes. 45 */ 46 47#define PRI_ITHD 1 /* Interrupt thread. */ 48#define PRI_REALTIME 2 /* Real time process. */ 49#define PRI_TIMESHARE 3 /* Time sharing process. */ 50#define PRI_IDLE 4 /* Idle process. */ 51 52/* 53 * PRI_FIFO is POSIX.1B SCHED_FIFO. 54 */ 55 56#define PRI_FIFO_BIT 8 57#define PRI_FIFO (PRI_FIFO_BIT | PRI_REALTIME) 58 59#define PRI_BASE(P) ((P) & ~PRI_FIFO_BIT) 60#define PRI_IS_REALTIME(P) (PRI_BASE(P) == PRI_REALTIME) 61#define PRI_NEED_RR(P) ((P) != PRI_FIFO) 62 63/* 64 * Priorities. Note that with 64 run queues, differences less than 4 are 65 * insignificant. 66 */ 67 68/* 69 * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ) 70 * are insignificant. Ranges are as follows: 71 * 72 * Interrupt threads: 0 - 47 73 * Realtime user threads: 48 - 79 74 * Top half kernel threads: 80 - 119 75 * Time sharing user threads: 120 - 223 76 * Idle user threads: 224 - 255 77 * 78 * XXX If/When the specific interrupt thread and top half thread ranges 79 * disappear, a larger range can be used for user processes. 80 */ 81 82#define PRI_MIN (0) /* Highest priority. */ 83#define PRI_MAX (255) /* Lowest priority. */ 84 85#define PRI_MIN_ITHD (PRI_MIN) 86#define PRI_MAX_ITHD (PRI_MIN_REALTIME - 1) 87 88#define PI_REALTIME (PRI_MIN_ITHD + 0) 89#define PI_AV (PRI_MIN_ITHD + 4) 90#define PI_NET (PRI_MIN_ITHD + 8) 91#define PI_DISK (PRI_MIN_ITHD + 12) 92#define PI_TTY (PRI_MIN_ITHD + 16) 93#define PI_DULL (PRI_MIN_ITHD + 20) 94#define PI_SOFT (PRI_MIN_ITHD + 24) 95#define PI_SWI(x) (PI_SOFT + (x) * RQ_PPQ) 96 97#define PRI_MIN_REALTIME (48) 98#define PRI_MAX_REALTIME (PRI_MIN_KERN - 1) 99 100#define PRI_MIN_KERN (80) 101#define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1) 102 103#define PSWP (PRI_MIN_KERN + 0) 104#define PVM (PRI_MIN_KERN + 4) 105#define PINOD (PRI_MIN_KERN + 8) 106#define PRIBIO (PRI_MIN_KERN + 12) 107#define PVFS (PRI_MIN_KERN + 16) 108#define PZERO (PRI_MIN_KERN + 20) 109#define PSOCK (PRI_MIN_KERN + 24) 110#define PWAIT (PRI_MIN_KERN + 28) 111#define PLOCK (PRI_MIN_KERN + 32) 112#define PPAUSE (PRI_MIN_KERN + 36) 113 114#define PRI_MIN_TIMESHARE (120) 115#define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1) 116 117#define PUSER (PRI_MIN_TIMESHARE) 118 119#define PRI_MIN_IDLE (224) 120#define PRI_MAX_IDLE (PRI_MAX) 121 122#ifdef _KERNEL 123/* Other arguments for kern_yield(9). */ 124#define PRI_USER -2 /* Change to current user priority. */ 125#define PRI_UNCHANGED -1 /* Do not change priority. */ 126#endif 127 128struct priority { 129 u_char pri_class; /* Scheduling class. */ 130 u_char pri_level; /* Normal priority level. */ 131 u_char pri_native; /* Priority before propagation. */ 132 u_char pri_user; /* User priority based on p_cpu and p_nice. */ 133}; 134 135#endif /* !_SYS_PRIORITY_H_ */ 136