45#include <sys/kernel.h>
47#include <sys/module.h>
51#include <sys/posix4.h>
52#include <sys/syscallsubr.h>
53#include <sys/sysctl.h>
54#include <sys/sysent.h>
55#include <sys/syslog.h>
56#include <sys/sysproto.h>
67 log(LOG_ERR,
"cmd %s pid %d tried to use non-present %s\n",
68 td->td_name, td->td_proc->p_pid, s);
76#if !defined(_KPOSIX_PRIORITY_SCHEDULING)
87SYSCALL_NOT_PRESENT_GEN(sched_setparam)
88SYSCALL_NOT_PRESENT_GEN(sched_getparam)
89SYSCALL_NOT_PRESENT_GEN(sched_setscheduler)
90SYSCALL_NOT_PRESENT_GEN(sched_getscheduler)
91SYSCALL_NOT_PRESENT_GEN(sched_yield)
92SYSCALL_NOT_PRESENT_GEN(sched_get_priority_max)
93SYSCALL_NOT_PRESENT_GEN(sched_get_priority_min)
94SYSCALL_NOT_PRESENT_GEN(sched_rr_get_interval)
107 p31b_setcfg(CTL_P1003_1B_PRIORITY_SCHEDULING, 200112L);
113sys_sched_setparam(
struct thread *td,
struct sched_setparam_args *uap)
115 struct thread *targettd;
116 struct proc *targetp;
118 struct sched_param sched_param;
120 e = copyin(uap->param, &sched_param,
sizeof(sched_param));
125 targetp = td->td_proc;
129 targetp =
pfind(uap->pid);
132 targettd = FIRST_THREAD_IN_PROC(targetp);
135 e = kern_sched_setparam(td, targettd, &sched_param);
136 PROC_UNLOCK(targetp);
141kern_sched_setparam(
struct thread *td,
struct thread *targettd,
142 struct sched_param *param)
144 struct proc *targetp;
147 targetp = targettd->td_proc;
148 PROC_LOCK_ASSERT(targetp, MA_OWNED);
153 (
const struct sched_param *)param);
158sys_sched_getparam(
struct thread *td,
struct sched_getparam_args *uap)
161 struct sched_param sched_param;
162 struct thread *targettd;
163 struct proc *targetp;
166 targetp = td->td_proc;
170 targetp =
pfind(uap->pid);
171 if (targetp == NULL) {
174 targettd = FIRST_THREAD_IN_PROC(targetp);
177 e = kern_sched_getparam(td, targettd, &sched_param);
178 PROC_UNLOCK(targetp);
180 e = copyout(&sched_param, uap->param,
sizeof(sched_param));
185kern_sched_getparam(
struct thread *td,
struct thread *targettd,
186 struct sched_param *param)
188 struct proc *targetp;
191 targetp = targettd->td_proc;
192 PROC_LOCK_ASSERT(targetp, MA_OWNED);
201sys_sched_setscheduler(
struct thread *td,
struct sched_setscheduler_args *uap)
204 struct sched_param sched_param;
205 struct thread *targettd;
206 struct proc *targetp;
208 e = copyin(uap->param, &sched_param,
sizeof(sched_param));
213 targetp = td->td_proc;
217 targetp =
pfind(uap->pid);
220 targettd = FIRST_THREAD_IN_PROC(targetp);
223 e = kern_sched_setscheduler(td, targettd, uap->policy,
225 PROC_UNLOCK(targetp);
230kern_sched_setscheduler(
struct thread *td,
struct thread *targettd,
231 int policy,
struct sched_param *param)
233 struct proc *targetp;
236 targetp = targettd->td_proc;
237 PROC_LOCK_ASSERT(targetp, MA_OWNED);
247 (
const struct sched_param *)param);
252sys_sched_getscheduler(
struct thread *td,
struct sched_getscheduler_args *uap)
255 struct thread *targettd;
256 struct proc *targetp;
259 targetp = td->td_proc;
263 targetp =
pfind(uap->pid);
266 targettd = FIRST_THREAD_IN_PROC(targetp);
269 e = kern_sched_getscheduler(td, targettd, &policy);
270 PROC_UNLOCK(targetp);
272 td->td_retval[0] = policy;
278kern_sched_getscheduler(
struct thread *td,
struct thread *targettd,
281 struct proc *targetp;
284 targetp = targettd->td_proc;
285 PROC_LOCK_ASSERT(targetp, MA_OWNED);
294sys_sched_yield(
struct thread *td,
struct sched_yield_args *uap)
302sys_sched_get_priority_max(
struct thread *td,
303 struct sched_get_priority_max_args *uap)
308 td->td_retval[0] = prio;
313sys_sched_get_priority_min(
struct thread *td,
314 struct sched_get_priority_min_args *uap)
319 td->td_retval[0] = prio;
324sys_sched_rr_get_interval(
struct thread *td,
325 struct sched_rr_get_interval_args *uap)
327 struct timespec timespec;
330 error = kern_sched_rr_get_interval(td, uap->pid, ×pec);
332 error = copyout(×pec, uap->interval,
sizeof(timespec));
337kern_sched_rr_get_interval(
struct thread *td, pid_t pid,
341 struct thread *targettd;
342 struct proc *targetp;
346 targetp = td->td_proc;
349 targetp =
pfind(pid);
352 targettd = FIRST_THREAD_IN_PROC(targetp);
355 e = kern_sched_rr_get_interval_td(td, targettd,
ts);
356 PROC_UNLOCK(targetp);
361kern_sched_rr_get_interval_td(
struct thread *td,
struct thread *targettd,
367 p = targettd->td_proc;
368 PROC_LOCK_ASSERT(p, MA_OWNED);
int priv_check(struct thread *td, int priv)
struct proc * pfind(pid_t pid)
int p_cansched(struct thread *td, struct proc *p)
int p_cansee(struct thread *td, struct proc *p)
int ksched_setscheduler(struct ksched *ksched, struct thread *td, int policy, const struct sched_param *param)
int ksched_get_priority_min(struct ksched *ksched, int policy, int *prio)
int ksched_setparam(struct ksched *ksched, struct thread *td, const struct sched_param *param)
int ksched_get_priority_max(struct ksched *ksched, int policy, int *prio)
int ksched_getscheduler(struct ksched *ksched, struct thread *td, int *policy)
int ksched_getparam(struct ksched *ksched, struct thread *td, struct sched_param *param)
int ksched_rr_get_interval(struct ksched *ksched, struct thread *td, struct timespec *timespec)
int ksched_attach(struct ksched **p)
int syscall_not_present(struct thread *td, const char *s, struct nosys_args *uap)
SYSINIT(p31b, SI_SUB_P1003_1B, SI_ORDER_FIRST, p31binit, NULL)
static int sched_attach(void)
MALLOC_DEFINE(M_P31B, "p1003.1b", "Posix 1003.1B")
static void p31binit(void *notused)
void p31b_setcfg(int num, int value)
void sched_relinquish(struct thread *td)
void log(int level, const char *fmt,...)