summaryrefslogtreecommitdiff
path: root/kernel/include/hilbert
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-07-31 13:36:53 -0400
committerBenji Dial <benji@benjidial.net>2024-07-31 13:36:53 -0400
commitb1cf9e5dfbc8967bd7cb2a22ec1e5e521f4e0e6e (patch)
tree00837891f9b9bf232e540a6f9b3e16f2438865c3 /kernel/include/hilbert
parent86b343f17175ef3e1fad2197636f75770466aa7c (diff)
downloadhilbert-os-b1cf9e5dfbc8967bd7cb2a22ec1e5e521f4e0e6e.tar.gz
add clock
Diffstat (limited to 'kernel/include/hilbert')
-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)