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 - 15 73 * Realtime user threads: 16 - 47 74 * Top half kernel threads: 48 - 87 75 * Time sharing user threads: 88 - 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 /* 89 * Most hardware interrupt threads run at the same priority, but can 90 * decay to lower priorities if they run for full time slices. 91 */ 92 #define PI_REALTIME (PRI_MIN_ITHD + 0) 93 #define PI_INTR (PRI_MIN_ITHD + 4) 94 #define PI_AV PI_INTR 95 #define PI_NET PI_INTR 96 #define PI_DISK PI_INTR 97 #define PI_TTY PI_INTR 98 #define PI_DULL PI_INTR 99 #define PI_SOFT (PRI_MIN_ITHD + 8) 100 #define PI_SOFTCLOCK PI_SOFT 101 #define PI_SWI(x) PI_SOFT 102 103 #define PRI_MIN_REALTIME (16) 104 #define PRI_MAX_REALTIME (PRI_MIN_KERN - 1) 105 106 #define PRI_MIN_KERN (48) 107 #define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1) 108 109 #define PSWP (PRI_MIN_KERN + 0) 110 #define PVM (PRI_MIN_KERN + 4) 111 #define PINOD (PRI_MIN_KERN + 8) 112 #define PRIBIO (PRI_MIN_KERN + 12) 113 #define PVFS (PRI_MIN_KERN + 16) 114 #define PZERO (PRI_MIN_KERN + 20) 115 #define PSOCK (PRI_MIN_KERN + 24) 116 #define PWAIT (PRI_MIN_KERN + 28) 117 #define PLOCK (PRI_MIN_KERN + 32) 118 #define PPAUSE (PRI_MIN_KERN + 36) 119 120 #define PRI_MIN_TIMESHARE (88) 121 #define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1) 122 123 #define PUSER (PRI_MIN_TIMESHARE) 124 125 #define PRI_MIN_IDLE (224) 126 #define PRI_MAX_IDLE (PRI_MAX) 127 128 #ifdef _KERNEL 129 /* Other arguments for kern_yield(9). */ 130 #define PRI_USER -2 /* Change to current user priority. */ 131 #define PRI_UNCHANGED -1 /* Do not change priority. */ 132 #endif 133 134 struct priority { 135 u_char pri_class; /* Scheduling class. */ 136 u_char pri_level; /* Normal priority level. */ 137 u_char pri_native; /* Priority before propagation. */ 138 u_char pri_user; /* User priority based on p_cpu and p_nice. */ 139 }; 140 141 #endif /* !_SYS_PRIORITY_H_ */ 142