FreeBSD/sys/kern/ksched.c
/*
 * XXX The priority and scheduler modifications should
 *     be moved into published interfaces in kern/kern_sync.
 *
 * The permissions to modify process p were checked in "p31b_proc()".
 *
 */
XXX The priority and scheduler modifications should
be moved into published interfaces in kern/kern_sync.

The permissions to modify process p were checked in "p31b_proc()".
XXX The priority and scheduler modifications should be moved into published interfaces in kern / kern_sync . The permissions to modify process p were checked in " p31b_proc () " .
int
ksched_setscheduler(struct ksched *ksched, struct thread *td, int policy,
    const struct sched_param *param)
{
	struct rtprio rtp;
	int e;
	e = 0;
	switch(policy) {
	case SCHED_RR:
	case SCHED_FIFO:
		if (param->sched_priority >= P1B_PRIO_MIN &&
		    param->sched_priority <= P1B_PRIO_MAX) {
			rtp.prio = p4prio_to_rtpprio(param->sched_priority);
			rtp.type = (policy == SCHED_FIFO) ? RTP_PRIO_FIFO :
			    RTP_PRIO_REALTIME;
			rtp_to_pri(&rtp, td);
		} else {
			e = EPERM;
		}
		break;
	case SCHED_OTHER:
		if (param->sched_priority >= 0 && param->sched_priority <=
		    (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE)) {
			rtp.type = RTP_PRIO_NORMAL;
			rtp.prio = p4prio_to_tsprio(param->sched_priority);
			rtp_to_pri(&rtp, td);
		} else {
			e = EINVAL;
		}
		break;
	default:
		e = EINVAL;
		break;
	}
	return (e);
}
int ksched_setscheduler ( struct ksched * ksched , struct thread * td , int policy , const struct sched_param * param ) { struct rtprio rtp ; int e ; e = 0 ; switch ( policy ) { case SCHED_RR : case SCHED_FIFO : if ( param -> sched_priority >= P1B_PRIO_MIN && param -> sched_priority <= P1B_PRIO_MAX ) { rtp . prio = p4prio_to_rtpprio ( param -> sched_priority ) ; rtp . type = ( policy == SCHED_FIFO ) ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME ; rtp_to_pri ( & rtp , td ) ; } else { e = EPERM ; } break ; case SCHED_OTHER : if ( param -> sched_priority >= 0 && param -> sched_priority <= ( PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE ) ) { rtp . type = RTP_PRIO_NORMAL ; rtp . prio = p4prio_to_tsprio ( param -> sched_priority ) ; rtp_to_pri ( & rtp , td ) ; } else { e = EINVAL ; } break ; default : e = EINVAL ; break ; } return ( e ) ; }
XXX The priority and scheduler modifications should
     be moved into published interfaces in kern/kern_sync.
XXX The priority and scheduler modifications should be moved into published interfaces in kern / kern_sync .