From 696d96607ea72f5593229da8cb8f40be06d70427 Mon Sep 17 00:00:00 2001 From: jb Date: Sun, 8 Mar 1998 02:37:27 +0000 Subject: Add sched_yield() witch is the draft 10 equivalent of pthread_yield() from draft 4. Move some of the schedule definitions to sched.h which is a POSIX header. --- lib/libc_r/uthread/pthread_private.h | 30 ++++++++---------------------- lib/libc_r/uthread/uthread_yield.c | 14 ++++++++++++++ lib/libkse/thread/thr_private.h | 30 ++++++++---------------------- lib/libkse/thread/thr_yield.c | 14 ++++++++++++++ lib/libpthread/thread/thr_private.h | 30 ++++++++---------------------- lib/libpthread/thread/thr_yield.c | 14 ++++++++++++++ 6 files changed, 66 insertions(+), 66 deletions(-) diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h index e0a0511..7d5bf89 100644 --- a/lib/libc_r/uthread/pthread_private.h +++ b/lib/libc_r/uthread/pthread_private.h @@ -52,6 +52,7 @@ #include #include #include +#include /* * Kernel fatal error handler macro. @@ -158,30 +159,15 @@ struct pthread_cleanup { void *routine_arg; }; -/* - * Scheduling definitions. - */ -enum schedparam_policy { - SCHED_RR, - SCHED_IO, - SCHED_FIFO, - SCHED_OTHER -}; - struct pthread_attr { - enum schedparam_policy schedparam_policy; - int prio; - int suspend; - int flags; - void *arg_attr; - void (*cleanup_attr) (); - void *stackaddr_attr; - size_t stacksize_attr; -}; - -struct sched_param { + int schedparam_policy; int prio; - void *no_data; + int suspend; + int flags; + void *arg_attr; + void (*cleanup_attr) (); + void *stackaddr_attr; + size_t stacksize_attr; }; /* diff --git a/lib/libc_r/uthread/uthread_yield.c b/lib/libc_r/uthread/uthread_yield.c index a88a948..877f5e6 100644 --- a/lib/libc_r/uthread/uthread_yield.c +++ b/lib/libc_r/uthread/uthread_yield.c @@ -34,6 +34,20 @@ #include #include "pthread_private.h" +int +sched_yield(void) +{ + /* Reset the accumulated time slice value for the current thread: */ + _thread_run->slice_usec = -1; + + /* Schedule the next thread: */ + _thread_kern_sched(NULL); + + /* Always return no error. */ + return(0); +} + +/* Draft 4 yield */ void pthread_yield(void) { diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h index e0a0511..7d5bf89 100644 --- a/lib/libkse/thread/thr_private.h +++ b/lib/libkse/thread/thr_private.h @@ -52,6 +52,7 @@ #include #include #include +#include /* * Kernel fatal error handler macro. @@ -158,30 +159,15 @@ struct pthread_cleanup { void *routine_arg; }; -/* - * Scheduling definitions. - */ -enum schedparam_policy { - SCHED_RR, - SCHED_IO, - SCHED_FIFO, - SCHED_OTHER -}; - struct pthread_attr { - enum schedparam_policy schedparam_policy; - int prio; - int suspend; - int flags; - void *arg_attr; - void (*cleanup_attr) (); - void *stackaddr_attr; - size_t stacksize_attr; -}; - -struct sched_param { + int schedparam_policy; int prio; - void *no_data; + int suspend; + int flags; + void *arg_attr; + void (*cleanup_attr) (); + void *stackaddr_attr; + size_t stacksize_attr; }; /* diff --git a/lib/libkse/thread/thr_yield.c b/lib/libkse/thread/thr_yield.c index a88a948..877f5e6 100644 --- a/lib/libkse/thread/thr_yield.c +++ b/lib/libkse/thread/thr_yield.c @@ -34,6 +34,20 @@ #include #include "pthread_private.h" +int +sched_yield(void) +{ + /* Reset the accumulated time slice value for the current thread: */ + _thread_run->slice_usec = -1; + + /* Schedule the next thread: */ + _thread_kern_sched(NULL); + + /* Always return no error. */ + return(0); +} + +/* Draft 4 yield */ void pthread_yield(void) { diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index e0a0511..7d5bf89 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -52,6 +52,7 @@ #include #include #include +#include /* * Kernel fatal error handler macro. @@ -158,30 +159,15 @@ struct pthread_cleanup { void *routine_arg; }; -/* - * Scheduling definitions. - */ -enum schedparam_policy { - SCHED_RR, - SCHED_IO, - SCHED_FIFO, - SCHED_OTHER -}; - struct pthread_attr { - enum schedparam_policy schedparam_policy; - int prio; - int suspend; - int flags; - void *arg_attr; - void (*cleanup_attr) (); - void *stackaddr_attr; - size_t stacksize_attr; -}; - -struct sched_param { + int schedparam_policy; int prio; - void *no_data; + int suspend; + int flags; + void *arg_attr; + void (*cleanup_attr) (); + void *stackaddr_attr; + size_t stacksize_attr; }; /* diff --git a/lib/libpthread/thread/thr_yield.c b/lib/libpthread/thread/thr_yield.c index a88a948..877f5e6 100644 --- a/lib/libpthread/thread/thr_yield.c +++ b/lib/libpthread/thread/thr_yield.c @@ -34,6 +34,20 @@ #include #include "pthread_private.h" +int +sched_yield(void) +{ + /* Reset the accumulated time slice value for the current thread: */ + _thread_run->slice_usec = -1; + + /* Schedule the next thread: */ + _thread_kern_sched(NULL); + + /* Always return no error. */ + return(0); +} + +/* Draft 4 yield */ void pthread_yield(void) { -- cgit v1.1