Ejemplo n.º 1
0
/*
 * 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(register_t *ret, struct ksched *ksched,
	struct proc *p, int policy, const struct sched_param *param)
{
	int e = 0;
	struct rtprio rtp;

	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;

			p->p_rtprio = rtp;
			need_resched();
		}
		else
			e = EPERM;


		break;

		case SCHED_OTHER:
		{
			rtp.type = RTP_PRIO_NORMAL;
			rtp.prio = p4prio_to_rtpprio(param->sched_priority);
			p->p_rtprio = rtp;

			/* XXX Simply revert to whatever we had for last
			 *     normal scheduler priorities.
			 *     This puts a requirement
			 *     on the scheduling code: You must leave the
			 *     scheduling info alone.
			 */
			need_resched();
		}
		break;
	}

	return e;
}
Ejemplo n.º 2
0
/*
 * 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)
{
	int e = 0;
	struct rtprio rtp;

	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_rtpprio(param->sched_priority);
			rtp_to_pri(&rtp, td);
		} else
			e = EINVAL;

		break;
		
		default:
			e = EINVAL;
			break;
	}

	return e;
}