1139825Simp/*-
22441Sdg * Copyright (c) 1994, Henrik Vestergaard Draboel
32441Sdg * All rights reserved.
42441Sdg *
52441Sdg * Redistribution and use in source and binary forms, with or without
62441Sdg * modification, are permitted provided that the following conditions
72441Sdg * are met:
82441Sdg * 1. Redistributions of source code must retain the above copyright
92441Sdg *    notice, this list of conditions and the following disclaimer.
102441Sdg * 2. Redistributions in binary form must reproduce the above copyright
112441Sdg *    notice, this list of conditions and the following disclaimer in the
122441Sdg *    documentation and/or other materials provided with the distribution.
132441Sdg * 3. All advertising materials mentioning features or use of this software
142441Sdg *    must display the following acknowledgement:
15165898Simp *	This product includes software developed by Henrik Vestergaard Draboel.
162441Sdg * 4. The name of the author may not be used to endorse or promote products
172441Sdg *    derived from this software without specific prior written permission.
182441Sdg *
192441Sdg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
202441Sdg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
212441Sdg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
222441Sdg * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
232441Sdg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
242441Sdg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
252441Sdg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
262441Sdg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
272441Sdg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
282441Sdg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
292441Sdg * SUCH DAMAGE.
302441Sdg *
3150477Speter * $FreeBSD$
322441Sdg */
332441Sdg
342441Sdg#ifndef _SYS_RTPRIO_H_
352441Sdg#define _SYS_RTPRIO_H_
362441Sdg
3772376Sjake#include <sys/priority.h>
3872376Sjake
392441Sdg/*
402441Sdg * Process realtime-priority specifications to rtprio.
412441Sdg */
422441Sdg
4365557Sjasone/* priority types.  Start at 1 to catch uninitialized fields. */
4434030Sdufault
4572376Sjake#define RTP_PRIO_REALTIME	PRI_REALTIME	/* real time process */
4672376Sjake#define RTP_PRIO_NORMAL		PRI_TIMESHARE	/* time sharing process */
4772376Sjake#define RTP_PRIO_IDLE		PRI_IDLE	/* idle process */
483291Sdg
4934925Sdufault/* RTP_PRIO_FIFO is POSIX.1B SCHED_FIFO.
5034030Sdufault */
5134030Sdufault
5272376Sjake#define RTP_PRIO_FIFO_BIT	PRI_FIFO_BIT
5372376Sjake#define RTP_PRIO_FIFO		PRI_FIFO
5472376Sjake#define RTP_PRIO_BASE(P)	PRI_BASE(P)
5572376Sjake#define RTP_PRIO_IS_REALTIME(P) PRI_IS_REALTIME(P)
5672376Sjake#define RTP_PRIO_NEED_RR(P)	PRI_NEED_RR(P)
5734030Sdufault
583291Sdg/* priority range */
593291Sdg#define RTP_PRIO_MIN		0	/* Highest priority */
603291Sdg#define RTP_PRIO_MAX		31	/* Lowest priority */
613291Sdg
623291Sdg/*
633291Sdg * rtprio() syscall functions
643291Sdg */
653291Sdg#define RTP_LOOKUP		0
663291Sdg#define RTP_SET			1
673291Sdg
683291Sdg#ifndef LOCORE
6965557Sjasone/*
7072376Sjake * Scheduling class information.
7165557Sjasone */
723291Sdgstruct rtprio {
7365557Sjasone	u_short type;			/* scheduling class */
743291Sdg	u_short prio;
753291Sdg};
7672376Sjake
7772376Sjake#ifdef _KERNEL
78163709Sjbstruct thread;
79163709Sjbint	rtp_to_pri(struct rtprio *, struct thread *);
80163709Sjbvoid	pri_to_rtp(struct thread *, struct rtprio *);
813291Sdg#endif
8272376Sjake#endif
833291Sdg
8455205Speter#ifndef _KERNEL
852441Sdg#include <sys/cdefs.h>
862441Sdg
872441Sdg__BEGIN_DECLS
8892719Salfredint	rtprio(int, pid_t, struct rtprio *);
89162497Sdavidxuint	rtprio_thread(int, lwpid_t, struct rtprio *);
902441Sdg__END_DECLS
9155205Speter#endif	/* !_KERNEL */
922441Sdg#endif	/* !_SYS_RTPRIO_H_ */
93