2 * Copyright (c) 1996, 1997
3 * HD Associates, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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 HD Associates, Inc
16 * and Jukka Antero Ukkonen.
17 * 4. Neither the name of the author nor the names of any co-contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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
35 * Copyright (c) 2002, Jeffrey Roberson <jeff@freebsd.org>
36 * All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice unmodified, this list of conditions, and the following
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
48 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
49 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
50 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
51 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
52 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
57 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 * General scheduling info.
70 * Total runnable non-ithread threads in the system.
73 * Runnable threads for this processor.
76 int sched_rr_interval(void);
77 int sched_runnable(void);
80 * Proc related scheduling hooks.
82 void sched_exit(struct proc *p, struct thread *childtd);
83 void sched_fork(struct thread *td, struct thread *childtd);
86 * KSE Groups contain scheduling priority information. They record the
87 * behavior of groups of KSEs and threads.
89 void sched_class(struct thread *td, int class);
90 void sched_nice(struct proc *p, int nice);
93 * Threads are switched in and out, block on resources, have temporary
94 * priorities inherited from their procs, and use up cpu time.
96 void sched_exit_thread(struct thread *td, struct thread *child);
97 void sched_fork_thread(struct thread *td, struct thread *child);
98 void sched_lend_prio(struct thread *td, u_char prio);
99 void sched_lend_user_prio(struct thread *td, u_char pri);
100 fixpt_t sched_pctcpu(struct thread *td);
101 void sched_prio(struct thread *td, u_char prio);
102 void sched_sleep(struct thread *td);
103 void sched_switch(struct thread *td, struct thread *newtd, int flags);
104 void sched_unlend_prio(struct thread *td, u_char prio);
105 void sched_unlend_user_prio(struct thread *td, u_char pri);
106 void sched_user_prio(struct thread *td, u_char prio);
107 void sched_userret(struct thread *td);
108 void sched_wakeup(struct thread *td);
111 * Threads are moved on and off of run queues
113 void sched_add(struct thread *td, int flags);
114 void sched_clock(struct thread *td);
115 void sched_rem(struct thread *td);
116 void sched_tick(void);
117 void sched_relinquish(struct thread *td);
120 * Binding makes cpu affinity permanent while pinning is used to temporarily
121 * hold a thread on a particular CPU.
123 void sched_bind(struct thread *td, int cpu);
124 static __inline void sched_pin(void);
125 void sched_unbind(struct thread *td);
126 static __inline void sched_unpin(void);
127 int sched_is_bound(struct thread *td);
130 * These procedures tell the process data structure allocation code how
131 * many bytes to actually allocate.
133 int sched_sizeof_proc(void);
134 int sched_sizeof_thread(void);
139 curthread->td_pinned++;
145 curthread->td_pinned--;
148 /* temporarily here */
149 void schedinit(void);
150 void sched_init_concurrency(struct proc *p);
151 void sched_set_concurrency(struct proc *p, int cuncurrency);
152 void sched_schedinit(void);
153 void sched_newproc(struct proc *p, struct thread *td);
154 void sched_thread_exit(struct thread *td);
155 void sched_newthread(struct thread *td);
158 /* POSIX 1003.1b Process Scheduling */
161 * POSIX scheduling policies
164 #define SCHED_OTHER 2
172 * POSIX scheduling declarations for userland.
175 #include <sys/cdefs.h>
176 #include <sys/_types.h>
178 #ifndef _PID_T_DECLARED
179 typedef __pid_t pid_t;
180 #define _PID_T_DECLARED
186 int sched_get_priority_max(int);
187 int sched_get_priority_min(int);
188 int sched_getparam(pid_t, struct sched_param *);
189 int sched_getscheduler(pid_t);
190 int sched_rr_get_interval(pid_t, struct timespec *);
191 int sched_setparam(pid_t, const struct sched_param *);
192 int sched_setscheduler(pid_t, int, const struct sched_param *);
193 int sched_yield(void);
197 #endif /* !_SCHED_H_ */