diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-08-12 13:32:03 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-08-12 23:29:30 +0200 |
commit | addb1071abb4e4013c1b75af4e6ed45ea1ccec3d (patch) | |
tree | 55371dc990b7971c9e049f2f1c2a29f7ede810ca /kern | |
parent | deb2b637605bf0beedb55ed5483f55af09ab41e9 (diff) | |
download | gnumach-addb1071abb4e4013c1b75af4e6ed45ea1ccec3d.tar.gz gnumach-addb1071abb4e4013c1b75af4e6ed45ea1ccec3d.tar.bz2 gnumach-addb1071abb4e4013c1b75af4e6ed45ea1ccec3d.zip |
sched: Add waitq_lock helpers which check they are called at spl7
Diffstat (limited to 'kern')
-rw-r--r-- | kern/sched_prim.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 793a09f2..0cd4ce59 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -131,6 +131,21 @@ timer_elt_data_t recompute_priorities_timer; decl_simple_lock_data(static, wait_lock[NUMQUEUES]) /* Lock for... */ queue_head_t wait_queue[NUMQUEUES]; +#ifdef MACH_LDEBUG +#define waitq_lock(wl) do { \ + assert(splsched() == SPL7); \ + simple_lock_nocheck(wl); \ +} while (0) +#define waitq_unlock(wl) do { \ + assert(splsched() == SPL7); \ + simple_unlock_nocheck(wl); \ +} while (0) +#else +#define waitq_lock(wl) simple_lock_nocheck(wl) +#define waitq_unlock(wl) simple_unlock_nocheck(wl) +#endif + + /* NOTE: we want a small positive integer out of this */ #define wait_hash(event) \ ((((long)(event) < 0) ? ~(long)(event) : (long)(event)) % NUMQUEUES) @@ -233,7 +248,7 @@ void assert_wait( index = wait_hash(event); q = &wait_queue[index]; lock = &wait_lock[index]; - simple_lock(lock); + waitq_lock(lock); thread_lock(thread); enqueue_tail(q, &(thread->links)); thread->wait_event = event; @@ -242,7 +257,7 @@ void assert_wait( else thread->state |= TH_WAIT | TH_UNINT; thread_unlock(thread); - simple_unlock(lock); + waitq_unlock(lock); } else { thread_lock(thread); @@ -295,7 +310,7 @@ void clear_wait( index = wait_hash(event); q = &wait_queue[index]; lock = &wait_lock[index]; - simple_lock(lock); + waitq_lock(lock); /* * If the thread is still waiting on that event, * then remove it from the list. If it is waiting @@ -308,7 +323,7 @@ void clear_wait( thread->wait_event = 0; event = 0; /* cause to run below */ } - simple_unlock(lock); + waitq_unlock(lock); } if (event == 0) { int state = thread->state; @@ -387,7 +402,7 @@ boolean_t thread_wakeup_prim( q = &wait_queue[index]; s = splsched(); lock = &wait_lock[index]; - simple_lock(lock); + waitq_lock(lock); thread = (thread_t) queue_first(q); while (!queue_end(q, (queue_entry_t)thread)) { next_th = (thread_t) queue_next((queue_t) thread); @@ -436,7 +451,7 @@ boolean_t thread_wakeup_prim( } thread = next_th; } - simple_unlock(lock); + waitq_unlock(lock); splx(s); return (woke); } |