diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-08 17:38:59 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-08 17:38:59 +0300 |
| commit | 7e828ec1e1479ff9a8afe845539d08ca0dfada5f (patch) | |
| tree | a227c58b30c99058fc10ff3caffeebca7dbd5913 /src/timer.c | |
| parent | 219c27d420fe0abe5515cefc2513c6fe60aafdf9 (diff) | |
| download | kmi-7e828ec1e1479ff9a8afe845539d08ca0dfada5f.tar.gz kmi-7e828ec1e1479ff9a8afe845539d08ca0dfada5f.zip | |
add orphan checking to timer and irq handling
Diffstat (limited to 'src/timer.c')
| -rw-r--r-- | src/timer.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/timer.c b/src/timer.c index 2d4ff01..573ed7b 100644 --- a/src/timer.c +++ b/src/timer.c @@ -16,14 +16,15 @@ */ #include <kmi/sp_tree.h> -#include <arch/timer.h> #include <kmi/string.h> #include <kmi/notify.h> #include <kmi/nodes.h> #include <kmi/utils.h> -#include <kmi/bkl.h> #include <kmi/timer.h> #include <kmi/debug.h> +#include <kmi/bkl.h> + +#include <arch/timer.h> #include <arch/cpu.h> /** Timer resolution. */ @@ -185,7 +186,7 @@ stat_t remove_timer(struct timer *t) struct sp_node *n = &timer_node_container(t)->sp_n; sp_remove(&sp_root(__cpu_timers()), n); - + free_node(&node_root, t); return OK; } @@ -198,12 +199,16 @@ ticks_t nsecs_to_ticks(tunit_t nsecs) /* call to this function from exception handlers */ void handle_timer() { + /** @todo should this also disable irqs? */ bkl_lock(); struct timer *t = newest_timer(); + id_t tid = t->tid; remove_timer(t); - struct tcb *r = get_tcb(t->tid); - if (!r) { + struct tcb *r = get_tcb(tid); + if (!r || orphan(r)) { + info("tcb %llu dead at timer\n", + (unsigned long long)tid); bkl_unlock(); return; } |
