aboutsummaryrefslogtreecommitdiff
path: root/src/lib/q.h
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2021-12-30 20:50:44 -0800
committerChristian Cunningham <cc@localhost>2021-12-30 20:50:44 -0800
commite15d41a5619c41f3440369e625d6d96921718221 (patch)
tree1291a6f4cb964d7143ab63626bc03ebefaff484b /src/lib/q.h
parent104c6fdd6b217b06183df7007882afa9183688bb (diff)
Added Data Structures
Added basic scheduling TODO: Preserve registers for context switch
Diffstat (limited to 'src/lib/q.h')
-rw-r--r--src/lib/q.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lib/q.h b/src/lib/q.h
new file mode 100644
index 0000000..51ff1a1
--- /dev/null
+++ b/src/lib/q.h
@@ -0,0 +1,30 @@
+#ifndef LIB_Q_H
+#define LIB_Q_H
+
+struct Q_base {
+ struct Q* next;
+ struct Q* last;
+};
+
+struct Q {
+ struct Q* next;
+ void* data;
+};
+
+struct Q_base* newq();
+void pushq(struct Q_base* qb, void* val);
+void popq(struct Q_base* qb);
+
+#define showq(QQ, TYPE) { \
+ if (QQ->next != 0) { \
+ struct Q* t = QQ->next; \
+ while (t->next != 0) { \
+ uart_hex(*(TYPE*)t->data); \
+ t = t->next; \
+ uart_char(' '); \
+ } \
+ uart_hex(*(TYPE*)t->data); \
+ } \
+}
+
+#endif