diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-11 11:54:49 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-12 13:24:41 +0200 |
commit | bd12dda405e1bab16c522f7ef0dd2b455230d269 (patch) | |
tree | c644df77b8512e1e211bfae39587511d0774f0d8 /testsuites/smptests/smpscheduler03 | |
parent | rtems: Avoid Giant lock rtems_task_is_suspended() (diff) | |
download | rtems-bd12dda405e1bab16c522f7ef0dd2b455230d269.tar.bz2 |
score: Use thread state lock for current state
In addition protect scheduler of thread by thread state lock. Enables
use of scheduler per-instance locks.
Update #2555.
Diffstat (limited to 'testsuites/smptests/smpscheduler03')
-rw-r--r-- | testsuites/smptests/smpscheduler03/init.c | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/testsuites/smptests/smpscheduler03/init.c b/testsuites/smptests/smpscheduler03/init.c index 4a3aa54ca5..1888048d28 100644 --- a/testsuites/smptests/smpscheduler03/init.c +++ b/testsuites/smptests/smpscheduler03/init.c @@ -193,11 +193,15 @@ static Thread_Control *change_priority_op( bool prepend_it ) { - const Scheduler_Control *scheduler = _Scheduler_Get(thread); + const Scheduler_Control *scheduler; + ISR_lock_Context state_lock_context; + ISR_lock_Context scheduler_lock_context; Thread_Control *needs_help; - ISR_lock_Context lock_context; - _Scheduler_Acquire(thread, &lock_context); + _Thread_State_acquire( thread, &state_lock_context ); + scheduler = _Scheduler_Get( thread ); + _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context ); + thread->current_priority = new_priority; needs_help = (*scheduler->Operations.change_priority)( scheduler, @@ -205,7 +209,9 @@ static Thread_Control *change_priority_op( new_priority, prepend_it ); - _Scheduler_Release(thread, &lock_context); + + _Scheduler_Release_critical( scheduler, &scheduler_lock_context ); + _Thread_State_release( thread, &state_lock_context ); return needs_help; } @@ -302,13 +308,19 @@ static void test_change_priority_op(void) static Thread_Control *yield_op(Thread_Control *thread) { - const Scheduler_Control *scheduler = _Scheduler_Get(thread); + const Scheduler_Control *scheduler; + ISR_lock_Context state_lock_context; + ISR_lock_Context scheduler_lock_context; Thread_Control *needs_help; - ISR_lock_Context lock_context; - _Scheduler_Acquire(thread, &lock_context); + _Thread_State_acquire( thread, &state_lock_context ); + scheduler = _Scheduler_Get( thread ); + _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context ); + needs_help = (*scheduler->Operations.yield)(scheduler, thread); - _Scheduler_Release(thread, &lock_context); + + _Scheduler_Release_critical( scheduler, &scheduler_lock_context ); + _Thread_State_release( thread, &state_lock_context ); return needs_help; } @@ -429,23 +441,35 @@ static void test_yield_op(void) static void block_op(Thread_Control *thread) { - const Scheduler_Control *scheduler = _Scheduler_Get(thread); - ISR_lock_Context lock_context; + const Scheduler_Control *scheduler; + ISR_lock_Context state_lock_context; + ISR_lock_Context scheduler_lock_context; + + _Thread_State_acquire( thread, &state_lock_context ); + scheduler = _Scheduler_Get( thread ); + _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context ); - _Scheduler_Acquire(thread, &lock_context); (*scheduler->Operations.block)(scheduler, thread); - _Scheduler_Release(thread, &lock_context); + + _Scheduler_Release_critical( scheduler, &scheduler_lock_context ); + _Thread_State_release( thread, &state_lock_context ); } static Thread_Control *unblock_op(Thread_Control *thread) { - const Scheduler_Control *scheduler = _Scheduler_Get(thread); + const Scheduler_Control *scheduler; + ISR_lock_Context state_lock_context; + ISR_lock_Context scheduler_lock_context; Thread_Control *needs_help; - ISR_lock_Context lock_context; - _Scheduler_Acquire(thread, &lock_context); + _Thread_State_acquire( thread, &state_lock_context ); + scheduler = _Scheduler_Get( thread ); + _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context ); + needs_help = (*scheduler->Operations.unblock)(scheduler, thread); - _Scheduler_Release(thread, &lock_context); + + _Scheduler_Release_critical( scheduler, &scheduler_lock_context ); + _Thread_State_release( thread, &state_lock_context ); return needs_help; } |