diff options
author | Alex Auvolat <alex@adnab.me> | 2015-03-13 18:02:01 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2015-03-13 18:02:01 +0100 |
commit | 151edb44eea9bf25ec466133e9dbef87bd6b1372 (patch) | |
tree | 14537daf1be1896a5453dcff21593a4233f1c3b5 /src/kernel/core/thread.c | |
parent | 5bc7fcc00507bbc5ff5bf957a1589209f8495534 (diff) | |
download | kogata-151edb44eea9bf25ec466133e9dbef87bd6b1372.tar.gz kogata-151edb44eea9bf25ec466133e9dbef87bd6b1372.zip |
Add missing mutex-locking in procesc.c ; discovered design fault somewhere.
Diffstat (limited to 'src/kernel/core/thread.c')
-rw-r--r-- | src/kernel/core/thread.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/kernel/core/thread.c b/src/kernel/core/thread.c index 1009ec7..53b3e70 100644 --- a/src/kernel/core/thread.c +++ b/src/kernel/core/thread.c @@ -43,8 +43,6 @@ void set_pit_frequency(uint32_t freq) { int enter_critical(int level) { asm volatile("cli"); - /*dbg_printf(" >%d< ", level);*/ - if (current_thread == 0) return CL_EXCL; int prev_level = current_thread->critical_level; @@ -52,18 +50,20 @@ int enter_critical(int level) { if (current_thread->critical_level < CL_NOINT) asm volatile("sti"); + /*dbg_printf(" >%d< ", current_thread->critical_level);*/ + return prev_level; } void exit_critical(int prev_level) { asm volatile("cli"); - /*dbg_printf(" <%d> ", prev_level);*/ - if (current_thread == 0) return; if (prev_level < current_thread->critical_level) current_thread->critical_level = prev_level; if (current_thread->critical_level < CL_NOINT) asm volatile("sti"); + + /*dbg_printf(" <%d> ", current_thread->critical_level);*/ } // ================== // @@ -315,12 +315,15 @@ bool wait_on_many(void** x, size_t n) { waiters = current_thread->next_waiter; } else { ASSERT(waiters != 0); + bool deleted = false; for (thread_t *w = waiters; w->next_waiter != 0; w = w->next_waiter) { if (w->next_waiter == current_thread) { w->next_waiter = current_thread->next_waiter; + deleted = true; break; } } + ASSERT(deleted); } exit_critical(st); |