summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c64
1 files changed, 49 insertions, 15 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 8af2be5..1feea8b 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -264,7 +264,8 @@ rtprio(curp, uap)
switch (uap->function) {
case RTP_LOOKUP:
- return (copyout(&p->p_rtprio, uap->rtp, sizeof(struct rtprio)));
+ pri_to_rtp(&p->p_pri, &rtp);
+ return (copyout(&rtp, uap->rtp, sizeof(struct rtprio)));
case RTP_SET:
if ((error = p_can(curp, p, P_CAN_SCHED, NULL)))
return (error);
@@ -287,26 +288,59 @@ rtprio(curp, uap)
if (rtp.type != RTP_PRIO_NORMAL)
return (EPERM);
}
- switch (rtp.type) {
-#ifdef RTP_PRIO_FIFO
- case RTP_PRIO_FIFO:
-#endif
- case RTP_PRIO_REALTIME:
- case RTP_PRIO_NORMAL:
- case RTP_PRIO_IDLE:
- if (rtp.prio > RTP_PRIO_MAX)
- return (EINVAL);
- p->p_rtprio = rtp;
+ if (rtp_to_pri(&rtp, &p->p_pri) == 0)
return (0);
- default:
- return (EINVAL);
- }
-
+ return (EINVAL);
default:
return (EINVAL);
}
}
+int
+rtp_to_pri(struct rtprio *rtp, struct priority *pri)
+{
+
+ if (rtp->prio > RTP_PRIO_MAX)
+ return (-1);
+ switch (RTP_PRIO_BASE(rtp->type)) {
+ case RTP_PRIO_REALTIME:
+ pri->pri_level = PRI_MIN_REALTIME + rtp->prio;
+ break;
+ case RTP_PRIO_NORMAL:
+ pri->pri_level = PRI_MIN_TIMESHARE + rtp->prio;
+ break;
+ case RTP_PRIO_IDLE:
+ pri->pri_level = PRI_MIN_IDLE + rtp->prio;
+ break;
+ default:
+ return (-1);
+ }
+ pri->pri_class = rtp->type;
+ pri->pri_native = pri->pri_level;
+ pri->pri_user = pri->pri_level;
+ return (0);
+}
+
+void
+pri_to_rtp(struct priority *pri, struct rtprio *rtp)
+{
+
+ switch (PRI_BASE(pri->pri_class)) {
+ case PRI_REALTIME:
+ rtp->prio = pri->pri_level - PRI_MIN_REALTIME;
+ break;
+ case PRI_TIMESHARE:
+ rtp->prio = pri->pri_level - PRI_MIN_TIMESHARE;
+ break;
+ case PRI_IDLE:
+ rtp->prio = pri->pri_level - PRI_MIN_IDLE;
+ break;
+ default:
+ break;
+ }
+ rtp->type = pri->pri_class;
+}
+
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
#ifndef _SYS_SYSPROTO_H_
struct osetrlimit_args {
OpenPOWER on IntegriCloud