From 739421ac52472d8dd2f23c141d449ff112fbf9b6 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 30 Sep 2014 09:08:44 +0200 Subject: 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. --- kern/sched_prim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'kern/sched_prim.c') diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 376217a8..d7792ae6 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -615,7 +615,7 @@ boolean_t thread_invoke( thread_lock(new_thread); new_thread->state &= ~TH_UNINT; thread_unlock(new_thread); - thread_wakeup(&new_thread->state); + thread_wakeup(TH_EV_STATE(new_thread)); if (continuation != (void (*)()) 0) { (void) spl0(); @@ -637,7 +637,7 @@ boolean_t thread_invoke( new_thread->state &= ~(TH_SWAPPED | TH_UNINT); thread_unlock(new_thread); - thread_wakeup(&new_thread->state); + thread_wakeup(TH_EV_STATE(new_thread)); #if NCPUS > 1 new_thread->last_processor = current_processor(); @@ -676,7 +676,7 @@ boolean_t thread_invoke( if (old_thread->wake_active) { old_thread->wake_active = FALSE; thread_unlock(old_thread); - thread_wakeup((event_t)&old_thread->wake_active); + thread_wakeup(TH_EV_WAKE_ACTIVE(old_thread)); goto after_old_thread; } @@ -767,7 +767,7 @@ boolean_t thread_invoke( new_thread->state &= ~(TH_SWAPPED | TH_UNINT); thread_unlock(new_thread); - thread_wakeup(&new_thread->state); + thread_wakeup(TH_EV_STATE(new_thread)); /* * Thread is now interruptible. @@ -932,7 +932,7 @@ void thread_dispatch( if (thread->wake_active) { thread->wake_active = FALSE; thread_unlock(thread); - thread_wakeup((event_t)&thread->wake_active); + thread_wakeup(TH_EV_WAKE_ACTIVE(thread)); return; } break; -- cgit v1.2.3