diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-09-30 09:08:44 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-02-20 18:46:55 +0100 |
commit | 739421ac52472d8dd2f23c141d449ff112fbf9b6 (patch) | |
tree | 43ae3d1931109f43c4532b9ead5554822bc21d6e /kern/thread.c | |
parent | b0fa32c1d7de74a8b83b33833640ff30c84e9fbd (diff) | |
download | gnumach-739421ac52472d8dd2f23c141d449ff112fbf9b6.tar.gz gnumach-739421ac52472d8dd2f23c141d449ff112fbf9b6.tar.bz2 gnumach-739421ac52472d8dd2f23c141d449ff112fbf9b6.zip |
kern: reduce the size of `struct thread'
Reduce the size of `struct thread' by twelve bytes making it fit into
exactly five cache lines (on 32-bit platforms).
* kern/thread.h (struct thread): Group the state and all flags in a
bitfield.
(TH_EV_WAKE_ACTIVE, TH_EV_STATE): Provide macros that generate keys
for synchronization primitives like `thread_wakeup'.
* kern/thread.c (thread_halt, thread_dowait, thread_suspend): Use the
new keys instead of addresses of fields for the synchronisation.
* kern/ipc_sched.c (thread_handoff): Likewise.
* kern/sched_prim.c (thread_invoke, thread_dispatch): Likewise.
Diffstat (limited to 'kern/thread.c')
-rw-r--r-- | kern/thread.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/kern/thread.c b/kern/thread.c index c627a06d..5ffa844e 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -968,7 +968,7 @@ kern_return_t thread_halt( * operation can never cause a deadlock.) */ if (cur_thread->ast & AST_HALT) { - thread_wakeup_with_result((event_t)&cur_thread->wake_active, + thread_wakeup_with_result(TH_EV_WAKE_ACTIVE(cur_thread), THREAD_INTERRUPTED); thread_unlock(thread); thread_unlock(cur_thread); @@ -1006,7 +1006,7 @@ kern_return_t thread_halt( */ while ((thread->ast & AST_HALT) && (!(thread->state & TH_HALTED))) { thread->wake_active = TRUE; - thread_sleep((event_t) &thread->wake_active, + thread_sleep(TH_EV_WAKE_ACTIVE(thread), simple_lock_addr(thread->lock), TRUE); if (thread->state & TH_HALTED) { @@ -1045,7 +1045,7 @@ kern_return_t thread_halt( s = splsched(); thread_lock(thread); thread_ast_clear(thread, AST_HALT); - thread_wakeup_with_result((event_t)&thread->wake_active, + thread_wakeup_with_result(TH_EV_WAKE_ACTIVE(thread), THREAD_INTERRUPTED); thread_unlock(thread); (void) splx(s); @@ -1284,7 +1284,7 @@ thread_dowait( * Check for failure if interrupted. */ thread->wake_active = TRUE; - thread_sleep((event_t) &thread->wake_active, + thread_sleep(TH_EV_WAKE_ACTIVE(thread), simple_lock_addr(thread->lock), TRUE); thread_lock(thread); if ((current_thread()->wait_result != THREAD_AWAKENED) && @@ -1308,7 +1308,7 @@ thread_dowait( (void) splx(s); if (need_wakeup) - thread_wakeup((event_t) &thread->wake_active); + thread_wakeup(TH_EV_WAKE_ACTIVE(thread)); return ret; } @@ -1346,7 +1346,7 @@ kern_return_t thread_suspend( thread_lock(thread); /* Wait for thread to get interruptible */ while (thread->state & TH_UNINT) { - assert_wait(&thread->state, TRUE); + assert_wait(TH_EV_STATE(thread), TRUE); thread_unlock(thread); thread_block(NULL); thread_lock(thread); |