1a9643ea8Slogwang /*- 2*22ce4affSfengbojiang * SPDX-License-Identifier: BSD-4-Clause 3*22ce4affSfengbojiang * 4a9643ea8Slogwang * Copyright (c) 1994, Henrik Vestergaard Draboel 5a9643ea8Slogwang * All rights reserved. 6a9643ea8Slogwang * 7a9643ea8Slogwang * Redistribution and use in source and binary forms, with or without 8a9643ea8Slogwang * modification, are permitted provided that the following conditions 9a9643ea8Slogwang * are met: 10a9643ea8Slogwang * 1. Redistributions of source code must retain the above copyright 11a9643ea8Slogwang * notice, this list of conditions and the following disclaimer. 12a9643ea8Slogwang * 2. Redistributions in binary form must reproduce the above copyright 13a9643ea8Slogwang * notice, this list of conditions and the following disclaimer in the 14a9643ea8Slogwang * documentation and/or other materials provided with the distribution. 15a9643ea8Slogwang * 3. All advertising materials mentioning features or use of this software 16a9643ea8Slogwang * must display the following acknowledgement: 17a9643ea8Slogwang * This product includes software developed by Henrik Vestergaard Draboel. 18a9643ea8Slogwang * 4. The name of the author may not be used to endorse or promote products 19a9643ea8Slogwang * derived from this software without specific prior written permission. 20a9643ea8Slogwang * 21a9643ea8Slogwang * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 22a9643ea8Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23a9643ea8Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24a9643ea8Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 25a9643ea8Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26a9643ea8Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27a9643ea8Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28a9643ea8Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29a9643ea8Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30a9643ea8Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31a9643ea8Slogwang * SUCH DAMAGE. 32a9643ea8Slogwang * 33a9643ea8Slogwang * $FreeBSD$ 34a9643ea8Slogwang */ 35a9643ea8Slogwang 36a9643ea8Slogwang #ifndef _SYS_RTPRIO_H_ 37a9643ea8Slogwang #define _SYS_RTPRIO_H_ 38a9643ea8Slogwang 39a9643ea8Slogwang #include <sys/priority.h> 40a9643ea8Slogwang 41a9643ea8Slogwang /* 42a9643ea8Slogwang * Process realtime-priority specifications to rtprio. 43a9643ea8Slogwang */ 44a9643ea8Slogwang 45a9643ea8Slogwang /* priority types. Start at 1 to catch uninitialized fields. */ 46a9643ea8Slogwang 47*22ce4affSfengbojiang #define RTP_PRIO_ITHD PRI_ITHD /* Interrupt thread. */ 48a9643ea8Slogwang #define RTP_PRIO_REALTIME PRI_REALTIME /* real time process */ 49a9643ea8Slogwang #define RTP_PRIO_NORMAL PRI_TIMESHARE /* time sharing process */ 50a9643ea8Slogwang #define RTP_PRIO_IDLE PRI_IDLE /* idle process */ 51a9643ea8Slogwang 52a9643ea8Slogwang /* RTP_PRIO_FIFO is POSIX.1B SCHED_FIFO. 53a9643ea8Slogwang */ 54a9643ea8Slogwang 55a9643ea8Slogwang #define RTP_PRIO_FIFO_BIT PRI_FIFO_BIT 56a9643ea8Slogwang #define RTP_PRIO_FIFO PRI_FIFO 57a9643ea8Slogwang #define RTP_PRIO_BASE(P) PRI_BASE(P) 58a9643ea8Slogwang #define RTP_PRIO_IS_REALTIME(P) PRI_IS_REALTIME(P) 59a9643ea8Slogwang #define RTP_PRIO_NEED_RR(P) PRI_NEED_RR(P) 60a9643ea8Slogwang 61a9643ea8Slogwang /* priority range */ 62a9643ea8Slogwang #define RTP_PRIO_MIN 0 /* Highest priority */ 63a9643ea8Slogwang #define RTP_PRIO_MAX 31 /* Lowest priority */ 64a9643ea8Slogwang 65a9643ea8Slogwang /* 66a9643ea8Slogwang * rtprio() syscall functions 67a9643ea8Slogwang */ 68a9643ea8Slogwang #define RTP_LOOKUP 0 69a9643ea8Slogwang #define RTP_SET 1 70a9643ea8Slogwang 71a9643ea8Slogwang #ifndef LOCORE 72a9643ea8Slogwang /* 73a9643ea8Slogwang * Scheduling class information. 74a9643ea8Slogwang */ 75a9643ea8Slogwang struct rtprio { 76a9643ea8Slogwang u_short type; /* scheduling class */ 77a9643ea8Slogwang u_short prio; 78a9643ea8Slogwang }; 79a9643ea8Slogwang 80a9643ea8Slogwang #ifdef _KERNEL 81a9643ea8Slogwang struct thread; 82a9643ea8Slogwang int rtp_to_pri(struct rtprio *, struct thread *); 83a9643ea8Slogwang void pri_to_rtp(struct thread *, struct rtprio *); 84a9643ea8Slogwang #endif 85a9643ea8Slogwang #endif 86a9643ea8Slogwang 87a9643ea8Slogwang #ifndef _KERNEL 88a9643ea8Slogwang #include <sys/cdefs.h> 89a9643ea8Slogwang 90a9643ea8Slogwang __BEGIN_DECLS 91a9643ea8Slogwang int rtprio(int, pid_t, struct rtprio *); 92a9643ea8Slogwang int rtprio_thread(int, lwpid_t, struct rtprio *); 93a9643ea8Slogwang __END_DECLS 94a9643ea8Slogwang #endif /* !_KERNEL */ 95a9643ea8Slogwang #endif /* !_SYS_RTPRIO_H_ */ 96