summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-11 11:54:49 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-12 13:24:41 +0200
commitbd12dda405e1bab16c522f7ef0dd2b455230d269 (patch)
treec644df77b8512e1e211bfae39587511d0774f0d8 /testsuites
parentrtems: Avoid Giant lock rtems_task_is_suspended() (diff)
downloadrtems-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')
-rw-r--r--testsuites/smptests/smpscheduler03/init.c56
-rw-r--r--testsuites/tmtests/tm27/task1.c18
2 files changed, 53 insertions, 21 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;
}
diff --git a/testsuites/tmtests/tm27/task1.c b/testsuites/tmtests/tm27/task1.c
index d351b4145a..77072bb91c 100644
--- a/testsuites/tmtests/tm27/task1.c
+++ b/testsuites/tmtests/tm27/task1.c
@@ -225,9 +225,15 @@ rtems_task Task_2(
)
{
Thread_Control *executing = _Thread_Get_executing();
- Scheduler_priority_Context *scheduler_context =
- _Scheduler_priority_Get_context( _Scheduler_Get( executing ) );
- ISR_lock_Context lock_context;
+ const Scheduler_Control *scheduler;
+ Scheduler_priority_Context *scheduler_context;
+ ISR_lock_Context state_lock_context;
+ ISR_lock_Context scheduler_lock_context;
+
+ _Thread_State_acquire( executing, &state_lock_context );
+ scheduler = _Scheduler_Get( executing );
+ scheduler_context = _Scheduler_priority_Get_context( scheduler );
+ _Thread_State_release( executing, &state_lock_context );
#if (MUST_WAIT_FOR_INTERRUPT == 1)
while ( Interrupt_occurred == 0 );
@@ -256,14 +262,16 @@ rtems_task Task_2(
* Switch back to the other task to exit the test.
*/
- _Scheduler_Acquire( executing, &lock_context );
+ _Thread_State_acquire( executing, &state_lock_context );
+ _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
_Thread_Executing =
(Thread_Control *) _Chain_First(&scheduler_context->Ready[LOW_PRIORITY]);
_Thread_Dispatch_necessary = 1;
- _Scheduler_Release( executing, &lock_context );
+ _Scheduler_Release_critical( scheduler, &scheduler_lock_context );
+ _Thread_State_release( executing, &state_lock_context );
_Thread_Dispatch();