summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/hilbert/kernel/timer.hpp18
-rw-r--r--kernel/include/hilbert/kernel/utility.hpp19
2 files changed, 37 insertions, 0 deletions
diff --git a/kernel/include/hilbert/kernel/timer.hpp b/kernel/include/hilbert/kernel/timer.hpp
new file mode 100644
index 0000000..f4ce17e
--- /dev/null
+++ b/kernel/include/hilbert/kernel/timer.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <hilbert/kernel/application.hpp>
+
+namespace hilbert::kernel::timer {
+
+ void init_timer();
+
+ //"mibiseconds" (1 second / 1024) since january 1st 2000
+ extern uint64_t current_time;
+
+ //when current_time >= sleeping_until, puts thread into paused threads
+ void register_sleeping_thread(
+ uint64_t sleeping_until, application::thread *thread);
+
+ void on_timer_interrupt();
+
+}
diff --git a/kernel/include/hilbert/kernel/utility.hpp b/kernel/include/hilbert/kernel/utility.hpp
index a21d3fe..b0ced32 100644
--- a/kernel/include/hilbert/kernel/utility.hpp
+++ b/kernel/include/hilbert/kernel/utility.hpp
@@ -126,6 +126,25 @@ namespace hilbert::kernel::utility {
last = n;
}
+ //if other == 0, then insert at the end
+ void insert_before(value_t &&value, node *other) {
+ node *n = new node {};
+ n->value = value;
+ n->next = other;
+ if (other) {
+ n->prev = other->prev;
+ other->prev = n;
+ }
+ else {
+ n->prev = last;
+ last = n;
+ }
+ if (n->prev)
+ n->prev->next = n;
+ else
+ first = n;
+ }
+
void clear() {
if (first) {
for (node *n = first->next; n; n = n->next)