summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/ksched.c17
-rw-r--r--sys/kern/p1003_1b.c18
-rw-r--r--sys/posix4/ksched.c17
-rw-r--r--sys/posix4/p1003_1b.c18
4 files changed, 52 insertions, 18 deletions
diff --git a/sys/kern/ksched.c b/sys/kern/ksched.c
index 20c5c57..3718e253 100644
--- a/sys/kern/ksched.c
+++ b/sys/kern/ksched.c
@@ -87,6 +87,11 @@ int ksched_detach(struct ksched *p)
#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
+/* These improve readability a bit for me:
+ */
+#define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX)
+#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
+
static __inline int
getscheduler(int *ret, struct ksched *ksched, struct proc *p)
{
@@ -155,15 +160,15 @@ int ksched_setscheduler(int *ret, struct ksched *ksched,
case SCHED_RR:
case SCHED_FIFO:
- if (param->sched_priority >= RTP_PRIO_MIN &&
- param->sched_priority <= RTP_PRIO_MAX)
+ 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.prio = p4prio_to_rtpprio(param->sched_priority);
p->p_rtprio = rtp;
- (void)resetpriority(p);
+ need_resched();
}
else
e = EPERM;
@@ -183,7 +188,7 @@ int ksched_setscheduler(int *ret, struct ksched *ksched,
* on the scheduling code: You must leave the
* scheduling info alone.
*/
- (void)resetpriority(p);
+ need_resched();
}
break;
}
@@ -234,7 +239,7 @@ int ksched_get_priority_min(int *ret, struct ksched *ksched, int policy)
{
case SCHED_FIFO:
case SCHED_RR:
- *ret = RTP_PRIO_MIN;
+ *ret = P1B_PRIO_MIN;
break;
case SCHED_OTHER:
diff --git a/sys/kern/p1003_1b.c b/sys/kern/p1003_1b.c
index c23d6a1..62ce150 100644
--- a/sys/kern/p1003_1b.c
+++ b/sys/kern/p1003_1b.c
@@ -162,10 +162,13 @@ int sched_setparam(struct proc *p,
{
int e;
+ struct sched_param sched_param;
+ copyin(uap->param, &sched_param, sizeof(sched_param));
+
(void) (0
|| (e = p31b_proc(p, uap->pid, &p))
|| (e = ksched_setparam(&p->p_retval[0], ksched, p,
- (const struct sched_param *) &uap->param))
+ (const struct sched_param *)&sched_param))
);
return e;
@@ -175,22 +178,31 @@ int sched_getparam(struct proc *p,
struct sched_getparam_args *uap)
{
int e;
+ struct sched_param sched_param;
(void) (0
|| (e = p31b_proc(p, uap->pid, &p))
- || (e = ksched_getparam(&p->p_retval[0], ksched, p, uap->param))
+ || (e = ksched_getparam(&p->p_retval[0], ksched, p, &sched_param))
);
+ if (!e)
+ copyout(&sched_param, uap->param, sizeof(sched_param));
+
return e;
}
int sched_setscheduler(struct proc *p,
struct sched_setscheduler_args *uap)
{
int e;
+
+ struct sched_param sched_param;
+ copyin(uap->param, &sched_param, sizeof(sched_param));
+
(void) (0
|| (e = p31b_proc(p, uap->pid, &p))
|| (e = ksched_setscheduler(&p->p_retval[0],
- ksched, p, uap->policy, uap->param))
+ ksched, p, uap->policy,
+ (const struct sched_param *)&sched_param))
);
return e;
diff --git a/sys/posix4/ksched.c b/sys/posix4/ksched.c
index 20c5c57..3718e253 100644
--- a/sys/posix4/ksched.c
+++ b/sys/posix4/ksched.c
@@ -87,6 +87,11 @@ int ksched_detach(struct ksched *p)
#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
+/* These improve readability a bit for me:
+ */
+#define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX)
+#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
+
static __inline int
getscheduler(int *ret, struct ksched *ksched, struct proc *p)
{
@@ -155,15 +160,15 @@ int ksched_setscheduler(int *ret, struct ksched *ksched,
case SCHED_RR:
case SCHED_FIFO:
- if (param->sched_priority >= RTP_PRIO_MIN &&
- param->sched_priority <= RTP_PRIO_MAX)
+ 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.prio = p4prio_to_rtpprio(param->sched_priority);
p->p_rtprio = rtp;
- (void)resetpriority(p);
+ need_resched();
}
else
e = EPERM;
@@ -183,7 +188,7 @@ int ksched_setscheduler(int *ret, struct ksched *ksched,
* on the scheduling code: You must leave the
* scheduling info alone.
*/
- (void)resetpriority(p);
+ need_resched();
}
break;
}
@@ -234,7 +239,7 @@ int ksched_get_priority_min(int *ret, struct ksched *ksched, int policy)
{
case SCHED_FIFO:
case SCHED_RR:
- *ret = RTP_PRIO_MIN;
+ *ret = P1B_PRIO_MIN;
break;
case SCHED_OTHER:
diff --git a/sys/posix4/p1003_1b.c b/sys/posix4/p1003_1b.c
index c23d6a1..62ce150 100644
--- a/sys/posix4/p1003_1b.c
+++ b/sys/posix4/p1003_1b.c
@@ -162,10 +162,13 @@ int sched_setparam(struct proc *p,
{
int e;
+ struct sched_param sched_param;
+ copyin(uap->param, &sched_param, sizeof(sched_param));
+
(void) (0
|| (e = p31b_proc(p, uap->pid, &p))
|| (e = ksched_setparam(&p->p_retval[0], ksched, p,
- (const struct sched_param *) &uap->param))
+ (const struct sched_param *)&sched_param))
);
return e;
@@ -175,22 +178,31 @@ int sched_getparam(struct proc *p,
struct sched_getparam_args *uap)
{
int e;
+ struct sched_param sched_param;
(void) (0
|| (e = p31b_proc(p, uap->pid, &p))
- || (e = ksched_getparam(&p->p_retval[0], ksched, p, uap->param))
+ || (e = ksched_getparam(&p->p_retval[0], ksched, p, &sched_param))
);
+ if (!e)
+ copyout(&sched_param, uap->param, sizeof(sched_param));
+
return e;
}
int sched_setscheduler(struct proc *p,
struct sched_setscheduler_args *uap)
{
int e;
+
+ struct sched_param sched_param;
+ copyin(uap->param, &sched_param, sizeof(sched_param));
+
(void) (0
|| (e = p31b_proc(p, uap->pid, &p))
|| (e = ksched_setscheduler(&p->p_retval[0],
- ksched, p, uap->policy, uap->param))
+ ksched, p, uap->policy,
+ (const struct sched_param *)&sched_param))
);
return e;
OpenPOWER on IntegriCloud