mirror of
https://github.com/opnsense/src.git
synced 2026-04-25 16:18:54 -04:00
- All processes go into the same array of queues, with different scheduling classes using different portions of the array. This allows user processes to have their priorities propogated up into interrupt thread range if need be. - I chose 64 run queues as an arbitrary number that is greater than 32. We used to have 4 separate arrays of 32 queues each, so this may not be optimal. The new run queue code was written with this in mind; changing the number of run queues only requires changing constants in runq.h and adjusting the priority levels. - The new run queue code takes the run queue as a parameter. This is intended to be used to create per-cpu run queues. Implement wrappers for compatibility with the old interface which pass in the global run queue structure. - Group the priority level, user priority, native priority (before propogation) and the scheduling class into a struct priority. - Change any hard coded priority levels that I found to use symbolic constants (TTIPRI and TTOPRI). - Remove the curpriority global variable and use that of curproc. This was used to detect when a process' priority had lowered and it should yield. We now effectively yield on every interrupt. - Activate propogate_priority(). It should now have the desired effect without needing to also propogate the scheduling class. - Temporarily comment out the call to vm_page_zero_idle() in the idle loop. It interfered with propogate_priority() because the idle process needed to do a non-blocking acquire of Giant and then other processes would try to propogate their priority onto it. The idle process should not do anything except idle. vm_page_zero_idle() will return in the form of an idle priority kernel thread which is woken up at apprioriate times by the vm system. - Update struct kinfo_proc to the new priority interface. Deliberately change its size by adjusting the spare fields. It remained the same size, but the layout has changed, so userland processes that use it would parse the data incorrectly. The size constraint should really be changed to an arbitrary version number. Also add a debug.sizeof sysctl node for struct kinfo_proc.
130 lines
4.3 KiB
C
130 lines
4.3 KiB
C
/*
|
|
* Copyright (c) 1994, Henrik Vestergaard Draboel
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
* must display the following acknowledgement:
|
|
* This product includes software developed by (name).
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
* derived from this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
#ifndef _SYS_PRIORITY_H_
|
|
#define _SYS_PRIORITY_H_
|
|
|
|
/*
|
|
* Process priority specifications.
|
|
*/
|
|
|
|
/*
|
|
* Priority classes.
|
|
*/
|
|
|
|
#define PRI_ITHD 1 /* Interrupt thread. */
|
|
#define PRI_REALTIME 2 /* Real time process. */
|
|
#define PRI_TIMESHARE 3 /* Time sharing process. */
|
|
#define PRI_IDLE 4 /* Idle process. */
|
|
|
|
/*
|
|
* PRI_FIFO is POSIX.1B SCHED_FIFO.
|
|
*/
|
|
|
|
#define PRI_FIFO_BIT 8
|
|
#define PRI_FIFO (PRI_FIFO_BIT | PRI_REALTIME)
|
|
|
|
#define PRI_BASE(P) ((P) & ~PRI_FIFO_BIT)
|
|
#define PRI_IS_REALTIME(P) (PRI_BASE(P) == PRI_REALTIME)
|
|
#define PRI_NEED_RR(P) ((P) != PRI_FIFO)
|
|
|
|
/*
|
|
* Priorities. Note that with 64 run queues, differences less than 4 are
|
|
* insignificant.
|
|
*/
|
|
|
|
/*
|
|
* Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ)
|
|
* are insignificant. Ranges are as follows:
|
|
*
|
|
* Interrupt threads: 0 - 63
|
|
* Top half kernel threads: 64 - 127
|
|
* Realtime user threads: 128 - 159
|
|
* Time sharing user threads: 160 - 223
|
|
* Idle user threads: 224 - 255
|
|
*
|
|
* XXX If/When the specific interrupt thread and top half thread ranges
|
|
* disappear, a larger range can be used for user processes.
|
|
*/
|
|
|
|
#define PRI_MIN (0) /* Highest priority. */
|
|
#define PRI_MAX (255) /* Lowest priority. */
|
|
|
|
#define PRI_MIN_ITHD (PRI_MIN)
|
|
#define PRI_MAX_ITHD (PRI_MIN_KERN - 1)
|
|
|
|
#define PI_REALTIME (PRI_MIN_ITHD + 0)
|
|
#define PI_AV (PRI_MIN_ITHD + 4)
|
|
#define PI_TTYHIGH (PRI_MIN_ITHD + 8)
|
|
#define PI_TAPE (PRI_MIN_ITHD + 12)
|
|
#define PI_NET (PRI_MIN_ITHD + 16)
|
|
#define PI_DISK (PRI_MIN_ITHD + 20)
|
|
#define PI_TTYLOW (PRI_MIN_ITHD + 24)
|
|
#define PI_DISKLOW (PRI_MIN_ITHD + 28)
|
|
#define PI_DULL (PRI_MIN_ITHD + 32)
|
|
#define PI_SOFT (PRI_MIN_ITHD + 36)
|
|
|
|
#define PRI_MIN_KERN (64)
|
|
#define PRI_MAX_KERN (PRI_MIN_REALTIME - 1)
|
|
|
|
#define PSWP (PRI_MIN_KERN + 0)
|
|
#define PVM (PRI_MIN_KERN + 4)
|
|
#define PINOD (PRI_MIN_KERN + 8)
|
|
#define PRIBIO (PRI_MIN_KERN + 12)
|
|
#define PVFS (PRI_MIN_KERN + 16)
|
|
#define PZERO (PRI_MIN_KERN + 20)
|
|
#define PSOCK (PRI_MIN_KERN + 24)
|
|
#define PWAIT (PRI_MIN_KERN + 28)
|
|
#define PCONFIG (PRI_MIN_KERN + 32)
|
|
#define PLOCK (PRI_MIN_KERN + 36)
|
|
#define PPAUSE (PRI_MIN_KERN + 40)
|
|
|
|
#define PRI_MIN_REALTIME (128)
|
|
#define PRI_MAX_REALTIME (PRI_MIN_TIMESHARE - 1)
|
|
|
|
#define PRI_MIN_TIMESHARE (160)
|
|
#define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1)
|
|
|
|
#define PUSER (PRI_MIN_TIMESHARE)
|
|
|
|
#define PRI_MIN_IDLE (224)
|
|
#define PRI_MAX_IDLE (PRI_MAX)
|
|
|
|
struct priority {
|
|
u_char pri_class; /* Scheduling class. */
|
|
u_char pri_level; /* Normal priority level. */
|
|
u_char pri_native; /* Priority before propogation. */
|
|
u_char pri_user; /* User priority based on p_cpu and p_nice. */
|
|
};
|
|
|
|
#endif /* !_SYS_PRIORITY_H_ */
|