36 #include <sys/cdefs.h>
39 #include "opt_posix.h"
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/kernel.h>
45 #include <sys/module.h>
46 #include <sys/mutex.h>
49 #include <sys/posix4.h>
50 #include <sys/syscallsubr.h>
51 #include <sys/sysctl.h>
52 #include <sys/sysent.h>
53 #include <sys/syslog.h>
54 #include <sys/sysproto.h>
65 log(LOG_ERR,
"cmd %s pid %d tried to use non-present %s\n",
66 td->td_name, td->td_proc->p_pid, s);
74 #if !defined(_KPOSIX_PRIORITY_SCHEDULING)
85 SYSCALL_NOT_PRESENT_GEN(sched_setparam)
86 SYSCALL_NOT_PRESENT_GEN(sched_getparam)
87 SYSCALL_NOT_PRESENT_GEN(sched_setscheduler)
88 SYSCALL_NOT_PRESENT_GEN(sched_getscheduler)
89 SYSCALL_NOT_PRESENT_GEN(sched_yield)
90 SYSCALL_NOT_PRESENT_GEN(sched_get_priority_max)
91 SYSCALL_NOT_PRESENT_GEN(sched_get_priority_min)
92 SYSCALL_NOT_PRESENT_GEN(sched_rr_get_interval)
105 p31b_setcfg(CTL_P1003_1B_PRIORITY_SCHEDULING, 200112L);
111 sys_sched_setparam(
struct thread *td,
struct sched_setparam_args *uap)
113 struct thread *targettd;
114 struct proc *targetp;
116 struct sched_param sched_param;
118 e = copyin(uap->param, &sched_param,
sizeof(sched_param));
123 targetp = td->td_proc;
127 targetp =
pfind(uap->pid);
130 targettd = FIRST_THREAD_IN_PROC(targetp);
136 (
const struct sched_param *)&sched_param);
138 PROC_UNLOCK(targetp);
143 sys_sched_getparam(
struct thread *td,
struct sched_getparam_args *uap)
146 struct sched_param sched_param;
147 struct thread *targettd;
148 struct proc *targetp;
151 targetp = td->td_proc;
155 targetp =
pfind(uap->pid);
156 if (targetp == NULL) {
159 targettd = FIRST_THREAD_IN_PROC(targetp);
166 PROC_UNLOCK(targetp);
168 e = copyout(&sched_param, uap->param,
sizeof(sched_param));
173 sys_sched_setscheduler(
struct thread *td,
struct sched_setscheduler_args *uap)
176 struct sched_param sched_param;
177 struct thread *targettd;
178 struct proc *targetp;
185 e = copyin(uap->param, &sched_param,
sizeof(sched_param));
190 targetp = td->td_proc;
194 targetp =
pfind(uap->pid);
197 targettd = FIRST_THREAD_IN_PROC(targetp);
203 uap->policy, (
const struct sched_param *)&sched_param);
205 PROC_UNLOCK(targetp);
210 sys_sched_getscheduler(
struct thread *td,
struct sched_getscheduler_args *uap)
213 struct thread *targettd;
214 struct proc *targetp;
217 targetp = td->td_proc;
221 targetp =
pfind(uap->pid);
224 targettd = FIRST_THREAD_IN_PROC(targetp);
230 td->td_retval[0] = policy;
232 PROC_UNLOCK(targetp);
238 sys_sched_yield(
struct thread *td,
struct sched_yield_args *uap)
246 sys_sched_get_priority_max(
struct thread *td,
247 struct sched_get_priority_max_args *uap)
252 td->td_retval[0] = prio;
257 sys_sched_get_priority_min(
struct thread *td,
258 struct sched_get_priority_min_args *uap)
263 td->td_retval[0] = prio;
268 sys_sched_rr_get_interval(
struct thread *td,
269 struct sched_rr_get_interval_args *uap)
271 struct timespec timespec;
274 error = kern_sched_rr_get_interval(td, uap->pid, ×pec);
276 error = copyout(×pec, uap->interval,
sizeof(timespec));
281 kern_sched_rr_get_interval(
struct thread *td, pid_t pid,
285 struct thread *targettd;
286 struct proc *targetp;
290 targetp = td->td_proc;
293 targetp =
pfind(pid);
296 targettd = FIRST_THREAD_IN_PROC(targetp);
302 PROC_UNLOCK(targetp);
int ksched_attach(struct ksched **p)
void sched_relinquish(struct thread *td)
int ksched_setscheduler(struct ksched *ksched, struct thread *td, int policy, const struct sched_param *param)
int ksched_getparam(struct ksched *ksched, struct thread *td, struct sched_param *param)
int ksched_get_priority_min(struct ksched *ksched, int policy, int *prio)
static void p31binit(void *notused)
int syscall_not_present(struct thread *td, const char *s, struct nosys_args *uap)
static int sched_attach(void)
int ksched_setparam(struct ksched *ksched, struct thread *td, const struct sched_param *param)
int priv_check(struct thread *td, int priv)
struct proc * pfind(pid_t pid)
int ksched_getscheduler(struct ksched *ksched, struct thread *td, int *policy)
void p31b_setcfg(int num, int value)
MALLOC_DEFINE(M_P31B,"p1003.1b","Posix 1003.1B")
void log(int level, const char *fmt,...)
SYSINIT(p31b, SI_SUB_P1003_1B, SI_ORDER_FIRST, p31binit, NULL)
int ksched_get_priority_max(struct ksched *ksched, int policy, int *prio)
int p_cansee(struct thread *td, struct proc *p)
int ksched_rr_get_interval(struct ksched *ksched, struct thread *td, struct timespec *timespec)
int p_cansched(struct thread *td, struct proc *p)