36 #include <sys/cdefs.h>
39 #include "opt_posix.h"
41 #include <sys/param.h>
42 #include <sys/systm.h>
44 #include <sys/sysctl.h>
45 #include <sys/kernel.h>
46 #include <sys/mutex.h>
48 #include <sys/posix4.h>
49 #include <sys/resource.h>
50 #include <sys/sched.h>
52 FEATURE(kposix_priority_scheduling,
"POSIX P1003.1B realtime extensions");
96 #define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
97 #define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
99 #define p4prio_to_tsprio(P) ((PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE) - (P))
100 #define tsprio_to_p4prio(P) ((PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE) - (P))
104 #define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX)
105 #define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
117 *policy = SCHED_FIFO;
120 case RTP_PRIO_REALTIME:
125 *policy = SCHED_OTHER;
134 struct thread *td,
const struct sched_param *param)
151 struct thread *td,
struct sched_param *param)
156 if (RTP_PRIO_IS_REALTIME(rtp.type))
159 if (PRI_MIN_TIMESHARE < rtp.prio)
164 param->sched_priority = (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE);
180 struct thread *td,
int policy,
const struct sched_param *param)
194 rtp.type = (policy == SCHED_FIFO)
195 ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME;
206 if (param->sched_priority >= 0 &&
207 param->sched_priority <= (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE)) {
208 rtp.type = RTP_PRIO_NORMAL;
248 *prio = RTP_PRIO_MAX;
252 *prio = PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE;
287 struct thread *td,
struct timespec *timespec)
int ksched_attach(struct ksched **p)
#define rtpprio_to_p4prio(P)
void sched_relinquish(struct thread *td)
int ksched_setscheduler(struct ksched *ksched, struct thread *td, int policy, const struct sched_param *param)
int ksched_getparam(struct ksched *ksched, struct thread *td, struct sched_param *param)
#define tsprio_to_p4prio(P)
int ksched_get_priority_min(struct ksched *ksched, int policy, int *prio)
int ksched_detach(struct ksched *ks)
FEATURE(kposix_priority_scheduling,"POSIX P1003.1B realtime extensions")
#define p4prio_to_tsprio(P)
int ksched_setparam(struct ksched *ksched, struct thread *td, const struct sched_param *param)
int rtp_to_pri(struct rtprio *rtp, struct thread *td)
int ksched_getscheduler(struct ksched *ksched, struct thread *td, int *policy)
int sched_rr_interval(void)
int ksched_yield(struct ksched *ksched)
static __inline int getscheduler(struct ksched *ksched, struct thread *td, int *policy)
#define p4prio_to_rtpprio(P)
int ksched_get_priority_max(struct ksched *ksched, int policy, int *prio)
void pri_to_rtp(struct thread *td, struct rtprio *rtp)
struct timespec rr_interval
int ksched_rr_get_interval(struct ksched *ksched, struct thread *td, struct timespec *timespec)