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