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.
This commit is contained in:
John Birrell
1998-03-08 02:37:27 +00:00
parent dc79e6f23b
commit 08d6f1187e
6 changed files with 66 additions and 66 deletions
+8 -22
View File
@@ -52,6 +52,7 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sched.h>
/*
* 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;
};
/*
+14
View File
@@ -34,6 +34,20 @@
#include <pthread.h>
#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)
{
+8 -22
View File
@@ -52,6 +52,7 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sched.h>
/*
* 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;
};
/*
+14
View File
@@ -34,6 +34,20 @@
#include <pthread.h>
#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)
{
+8 -22
View File
@@ -52,6 +52,7 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sched.h>
/*
* 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;
};
/*
+14
View File
@@ -34,6 +34,20 @@
#include <pthread.h>
#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)
{