summaryrefslogtreecommitdiffstats
path: root/sys/kern/ksched.c
diff options
context:
space:
mode:
authordufault <dufault@FreeBSD.org>1998-03-28 11:51:01 +0000
committerdufault <dufault@FreeBSD.org>1998-03-28 11:51:01 +0000
commit8ed0defc6e5c9d291026302e0d45357454484c5d (patch)
tree805e852c0dbabdcdb6254773c9023caa32928e3a /sys/kern/ksched.c
parentcd450d67141a2e84500ff624dc9d39c255a7de77 (diff)
downloadFreeBSD-src-8ed0defc6e5c9d291026302e0d45357454484c5d.zip
FreeBSD-src-8ed0defc6e5c9d291026302e0d45357454484c5d.tar.gz
Finish _POSIX_PRIORITY_SCHEDULING. Needs P1003_1B and
_KPOSIX_PRIORITY_SCHEDULING options to work. Changes: Change all "posix4" to "p1003_1b". Misnamed files are left as "posix4" until I'm told if I can simply delete them and add new ones; Add _POSIX_PRIORITY_SCHEDULING system calls for FreeBSD and Linux; Add man pages for _POSIX_PRIORITY_SCHEDULING system calls; Add options to LINT; Minor fixes to P1003_1B code during testing.
Diffstat (limited to 'sys/kern/ksched.c')
-rw-r--r--sys/kern/ksched.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/sys/kern/ksched.c b/sys/kern/ksched.c
index 7ff85d6..90c029a 100644
--- a/sys/kern/ksched.c
+++ b/sys/kern/ksched.c
@@ -39,34 +39,38 @@
#include <sys/proc.h>
#include <sys/kernel.h>
#include <machine/cpu.h> /* For need_resched */
-#include <fcntl.h>
-#include <sys/posix4.h>
+#include <posix4/posix4.h>
/* ksched: Real-time extension to support POSIX priority scheduling.
*/
-static struct timespec rr_interval;
+struct ksched {
+ struct timespec rr_interval;
+};
-int ksched_attach(int p4_instance, int fac_code, void **p)
+int ksched_attach(struct ksched **p)
{
- rr_interval.tv_sec = 0;
- rr_interval.tv_nsec = 1000000000L / roundrobin_interval();
+ struct ksched *ksched= p31b_malloc(sizeof(*ksched));
- *p = 0;
+ ksched->rr_interval.tv_sec = 0;
+ ksched->rr_interval.tv_nsec = 1000000000L / roundrobin_interval();
+ *p = ksched;
return 0;
}
-int ksched_detach(void *p)
+int ksched_detach(struct ksched *p)
{
+ p31b_free(p);
+
return 0;
}
/*
* XXX About priorities
*
- * POSIX4 requires that numerically higher priorities be of
+ * POSIX 1003.1b requires that numerically higher priorities be of
* higher priority. It also permits sched_setparam to be
* implementation defined for SCHED_OTHER. I don't like
* the notion of inverted priorites for normal processes when
@@ -76,14 +80,14 @@ int ksched_detach(void *p)
*/
/* Macros to convert between the unix (lower numerically is higher priority)
- * and POSIX4 (higher numerically is higher priority)
+ * and POSIX 1003.1b (higher numerically is higher priority)
*/
#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
static inline int
-getscheduler(int *ret, void *hook, struct proc *p)
+getscheduler(int *ret, struct ksched *ksched, struct proc *p)
{
int e = 0;
@@ -105,25 +109,25 @@ getscheduler(int *ret, void *hook, struct proc *p)
return e;
}
-int ksched_setparam(int *ret, void *hook,
+int ksched_setparam(int *ret, struct ksched *ksched,
struct proc *p, const struct sched_param *param)
{
int e, policy;
- e = getscheduler(&policy, hook, p);
+ e = getscheduler(&policy, ksched, p);
if (e == 0)
{
if (policy == SCHED_OTHER)
e = EINVAL;
else
- e = ksched_setscheduler(ret, hook, p, policy, param);
+ e = ksched_setscheduler(ret, ksched, p, policy, param);
}
return e;
}
-int ksched_getparam(int *ret, void *hook,
+int ksched_getparam(int *ret, struct ksched *ksched,
struct proc *p, struct sched_param *param)
{
if (RTP_PRIO_IS_REALTIME(p->p_rtprio.type))
@@ -136,10 +140,10 @@ int ksched_getparam(int *ret, void *hook,
* XXX The priority and scheduler modifications should
* be moved into published interfaces in kern/kern_sync.
*
- * The permissions to modify process p were checked in "posix4proc()".
+ * The permissions to modify process p were checked in "p31b_proc()".
*
*/
-int ksched_setscheduler(int *ret, void *hook,
+int ksched_setscheduler(int *ret, struct ksched *ksched,
struct proc *p, int policy, const struct sched_param *param)
{
int e = 0;
@@ -186,20 +190,20 @@ int ksched_setscheduler(int *ret, void *hook,
return e;
}
-int ksched_getscheduler(int *ret, void *hook, struct proc *p)
+int ksched_getscheduler(int *ret, struct ksched *ksched, struct proc *p)
{
- return getscheduler(ret, hook, p);
+ return getscheduler(ret, ksched, p);
}
/* ksched_yield: Yield the CPU.
*/
-int ksched_yield(int *ret, void *hook)
+int ksched_yield(int *ret, struct ksched *ksched)
{
need_resched();
return 0;
}
-int ksched_get_priority_max(int *ret, void *hook, int policy)
+int ksched_get_priority_max(int *ret, struct ksched *ksched, int policy)
{
int e = 0;
@@ -221,7 +225,7 @@ int ksched_get_priority_max(int *ret, void *hook, int policy)
return e;
}
-int ksched_get_priority_min(int *ret, void *hook, int policy)
+int ksched_get_priority_min(int *ret, struct ksched *ksched, int policy)
{
int e = 0;
@@ -243,10 +247,10 @@ int ksched_get_priority_min(int *ret, void *hook, int policy)
return e;
}
-int ksched_rr_get_interval(int *ret, void *hook,
+int ksched_rr_get_interval(int *ret, struct ksched *ksched,
struct proc *p, struct timespec *timespec)
{
- *timespec = rr_interval;
+ *timespec = ksched->rr_interval;
return 0;
}
OpenPOWER on IntegriCloud