summaryrefslogtreecommitdiff
path: root/kern/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'kern/thread.h')
-rw-r--r--kern/thread.h27
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.