aboutsummaryrefslogtreecommitdiff
path: root/kernel/task/include/task/task.h
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2014-03-17 15:53:45 +0100
committerJakob Odersky <jodersky@gmail.com>2014-03-17 15:53:45 +0100
commit5466218a5f9fb3d46f608806f222fcc99a306a4b (patch)
tree2d82056fe24bc508a985881149595fd83760b72a /kernel/task/include/task/task.h
parentd106637504ec4cb5fa63feab11bd845faea2bc07 (diff)
downloadmux-5466218a5f9fb3d46f608806f222fcc99a306a4b.tar.gz
mux-5466218a5f9fb3d46f608806f222fcc99a306a4b.tar.bz2
mux-5466218a5f9fb3d46f608806f222fcc99a306a4b.zip
no time scheduler
Diffstat (limited to 'kernel/task/include/task/task.h')
-rw-r--r--kernel/task/include/task/task.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/kernel/task/include/task/task.h b/kernel/task/include/task/task.h
new file mode 100644
index 0000000..40f18a0
--- /dev/null
+++ b/kernel/task/include/task/task.h
@@ -0,0 +1,45 @@
+#ifndef TASK_H
+#define TASK_H
+
+#include "collection/list.h"
+
+/**
+ * Task control block, contains runtime
+ * information about tasks.
+ */
+struct tcb_t {
+ /** Stack pointer of this task. (must be first in structure) */
+ char* volatile sp;
+
+ /** Lowest address of this task's memory (inclusive). */
+ char* mem_low;
+
+ /** Highest address of this task's memory (inclusive). */
+ char* mem_high;
+
+ /** Entry function of this task. */
+ void (*entry)(char);
+
+ /** Current wait queue that this task is in.*/
+ struct list_head queue;
+
+ char id;
+
+};
+
+/**
+ * Utility for declaring a task with statically allocated memory.
+ * Note: for a task to be scheduled, it must first be spawned (see spawn()).
+*/
+#define DECLARE_TASK(name, stack_size, entry_function, pid) \
+ static char _declared_stack_##name[stack_size]; \
+ static struct tcb_t name = { \
+ .sp = 0, \
+ .mem_low = _declared_stack_##name, \
+ .mem_high = _declared_stack_##name + stack_size - 1, \
+ .entry = entry_function, \
+ .queue = {}, \
+ .id = pid \
+ };
+
+#endif \ No newline at end of file