diff options
author | Richard Braun <rbraun@sceen.net> | 2013-03-03 23:20:22 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2013-03-03 23:20:22 +0100 |
commit | 77cd94102f49cf4fd4c2d76636e3d220d036d201 (patch) | |
tree | 3b29beb188336b43c26383e5c499ee9d6cb50f5a /kern/thread.h | |
parent | 890d1bb61a027c6742a1565d023572d144b76988 (diff) |
kern/thread: implement thread_sleep and thread_wakeup
For now, thread_wakeup can only wake up a thread on the same processor
as the caller. This is needed to properly implement thread migration.
Diffstat (limited to 'kern/thread.h')
-rw-r--r-- | kern/thread.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/kern/thread.h b/kern/thread.h index 9b8017c9..a7c50ca6 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -41,6 +41,12 @@ struct task; #define THREAD_RESCHEDULE 0x1 /* Thread marked for reschedule */ /* + * Thread states. + */ +#define THREAD_RUNNING 0 +#define THREAD_SLEEPING 1 + +/* * Scheduling policies. * * The idle policy is reserved for the per-CPU idle threads. @@ -99,9 +105,12 @@ struct thread_ts_ctx { */ struct thread { struct tcb tcb; + short state; short flags; unsigned short pinned; unsigned short preempt; + unsigned int cpu; + unsigned long on_rq; /* Common scheduling properties */ unsigned char sched_policy; @@ -161,6 +170,24 @@ int thread_create(struct thread **threadp, const struct thread_attr *attr, void (*fn)(void *), void *arg); /* + * Make the scheduler remove the calling thread from its run queue. + * + * This is a low level thread control primitive that should only be called by + * higher thread synchronization functions. + */ +void thread_sleep(void); + +/* + * Schedule the target thread for execution on a processor. + * + * No action is performed if the target thread is already on a run queue. + * + * This is a low level thread control primitive that should only be called by + * higher thread synchronization functions. + */ +void thread_wakeup(struct thread *thread); + +/* * Start running threads on the local processor. * * Interrupts must be enabled when calling this function. |