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$ 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 * 70217410Sjhb * Interrupt threads: 0 - 47 71217410Sjhb * Realtime user threads: 48 - 79 72217410Sjhb * Top half kernel threads: 80 - 119 73217410Sjhb * Time sharing user threads: 120 - 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) 84217410Sjhb#define PRI_MAX_ITHD (PRI_MIN_REALTIME - 1) 8572376Sjake 8672376Sjake#define PI_REALTIME (PRI_MIN_ITHD + 0) 8772376Sjake#define PI_AV (PRI_MIN_ITHD + 4) 88217292Sjhb#define PI_NET (PRI_MIN_ITHD + 8) 89217292Sjhb#define PI_DISK (PRI_MIN_ITHD + 12) 90217292Sjhb#define PI_TTY (PRI_MIN_ITHD + 16) 91217292Sjhb#define PI_DULL (PRI_MIN_ITHD + 20) 92217292Sjhb#define PI_SOFT (PRI_MIN_ITHD + 24) 93217292Sjhb#define PI_SWI(x) (PI_SOFT + (x) * RQ_PPQ) 9472376Sjake 95217410Sjhb#define PRI_MIN_REALTIME (48) 96217410Sjhb#define PRI_MAX_REALTIME (PRI_MIN_KERN - 1) 9772376Sjake 98217410Sjhb#define PRI_MIN_KERN (80) 99217410Sjhb#define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1) 100217410Sjhb 10172376Sjake#define PSWP (PRI_MIN_KERN + 0) 10272376Sjake#define PVM (PRI_MIN_KERN + 4) 10372376Sjake#define PINOD (PRI_MIN_KERN + 8) 10472376Sjake#define PRIBIO (PRI_MIN_KERN + 12) 10572376Sjake#define PVFS (PRI_MIN_KERN + 16) 10672376Sjake#define PZERO (PRI_MIN_KERN + 20) 10772376Sjake#define PSOCK (PRI_MIN_KERN + 24) 10872376Sjake#define PWAIT (PRI_MIN_KERN + 28) 109217075Sjhb#define PLOCK (PRI_MIN_KERN + 32) 110217075Sjhb#define PPAUSE (PRI_MIN_KERN + 36) 11172376Sjake 112217410Sjhb#define PRI_MIN_TIMESHARE (120) 11372376Sjake#define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1) 11472376Sjake 11572376Sjake#define PUSER (PRI_MIN_TIMESHARE) 11672376Sjake 11772376Sjake#define PRI_MIN_IDLE (224) 11872376Sjake#define PRI_MAX_IDLE (PRI_MAX) 11972376Sjake 120221829Smdf#ifdef _KERNEL 121221829Smdf/* Other arguments for kern_yield(9). */ 122221829Smdf#define PRI_USER -2 /* Change to current user priority. */ 123221829Smdf#define PRI_UNCHANGED -1 /* Do not change priority. */ 124221829Smdf#endif 125221829Smdf 12683045Sobrienstruct priority { 12772376Sjake u_char pri_class; /* Scheduling class. */ 12872376Sjake u_char pri_level; /* Normal priority level. */ 129298981Spfg u_char pri_native; /* Priority before propagation. */ 13072376Sjake u_char pri_user; /* User priority based on p_cpu and p_nice. */ 13172376Sjake}; 13272376Sjake 13372376Sjake#endif /* !_SYS_PRIORITY_H_ */ 134