int ksched_setparam(struct ksched *ksched, struct thread *td, const struct sched_param *param) { int policy; int e; e = getscheduler(ksched, td, &policy); if (e == 0) { e = ksched_setscheduler(ksched, td, policy, param); } return e; }
int ksched_setparam(register_t *ret, struct ksched *ksched, struct proc *p, const struct sched_param *param) { register_t policy; int e; e = getscheduler(&policy, ksched, p); if (e == 0) { if (policy == SCHED_OTHER) e = EINVAL; else e = ksched_setscheduler(ret, ksched, p, policy, param); } return e; }
int sys_sched_setscheduler(struct thread *td, struct sched_setscheduler_args *uap) { int e; struct sched_param sched_param; struct thread *targettd; struct proc *targetp; /* Don't allow non root user to set a scheduler policy. */ e = priv_check(td, PRIV_SCHED_SET); if (e) return (e); e = copyin(uap->param, &sched_param, sizeof(sched_param)); if (e) return (e); if (uap->pid == 0) { targetp = td->td_proc; targettd = td; PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); if (targetp == NULL) return (ESRCH); targettd = FIRST_THREAD_IN_PROC(targetp); } e = p_cansched(td, targetp); if (e == 0) { e = ksched_setscheduler(ksched, targettd, uap->policy, (const struct sched_param *)&sched_param); } PROC_UNLOCK(targetp); return (e); }