BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / db9a0c170420002cff8cade7e3e598ac9d6fb25a / include / nucleus / task.h

// Related

Nucleus

Barry Multitasking support db9a0c1 (3 years, 3 months ago)
diff --git a/include/nucleus/task.h b/include/nucleus/task.h
new file mode 100644
index 0000000..2761a3f
--- /dev/null
+++ b/include/nucleus/task.h
@@ -0,0 +1,50 @@
+#ifndef _NUCLEUS_TASK_H
+#define _NUCLEUS_TASK_H
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <nucleus/cpu.h>
+#include <nucleus/object.h>
+#include <nucleus/memory.h>
+
+typedef struct Task Task;
+
+/* Task priorities */
+enum Priority {
+	NONE,
+	LOWEST,
+	LOW,
+	NORMAL,
+	HIGH,
+	HIGHEST,
+};
+
+/* Task states */
+enum State {
+	RUNNING,
+	READY,
+	TERMINATED,
+};
+
+/* Structure for a Task */
+struct Task {
+	Object obj;
+	pid_t tid;
+	enum Priority priority;
+	enum State state;
+
+	uintptr_t esp, ebp, eip;
+	page_dir_t pageDir;
+	Task *next;
+};
+
+extern ObjectType taskType;
+
+extern Task *currentTask[];
+#define current currentTask[CPUID]
+
+void init_tasking(void);
+void schedule(void);
+pid_t clone(int flags);
+
+#endif