From 9bfad8cd519f17cbb26a672868169fcd304d5bd5 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 8 Jun 2016 22:22:46 +0200 Subject: score: Add thread priority to scheduler nodes The thread priority is manifest in two independent areas. One area is the user visible thread priority along with a potential thread queue. The other is the scheduler. Currently, a thread priority update via _Thread_Change_priority() first updates the user visble thread priority and the thread queue, then the scheduler is notified if necessary. The priority is passed to the scheduler via a local variable. A generation counter ensures that the scheduler discards out-of-date priorities. This use of a local variable ties the update in these two areas close together. For later enhancements and the OMIP locking protocol implementation we need more flexibility. Add a thread priority information block to Scheduler_Node and synchronize priority value updates via a sequence lock on SMP configurations. Update #2556. --- testsuites/smptests/smpscheduler03/init.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'testsuites/smptests/smpscheduler03') diff --git a/testsuites/smptests/smpscheduler03/init.c b/testsuites/smptests/smpscheduler03/init.c index d6a145c3d5..f610b62532 100644 --- a/testsuites/smptests/smpscheduler03/init.c +++ b/testsuites/smptests/smpscheduler03/init.c @@ -187,7 +187,7 @@ static void test_change_priority(void) rtems_test_assert(sc == RTEMS_SUCCESSFUL); } -static Thread_Control *change_priority_op( +static Thread_Control *update_priority_op( Thread_Control *thread, Priority_Control new_priority, bool prepend_it @@ -197,18 +197,17 @@ static Thread_Control *change_priority_op( ISR_lock_Context state_lock_context; ISR_lock_Context scheduler_lock_context; Thread_Control *needs_help; + Scheduler_Node *node; + + thread->current_priority = new_priority; + node = _Scheduler_Thread_get_node(thread); + _Scheduler_Node_set_priority(node, new_priority, prepend_it); _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, - thread, - new_priority, - prepend_it - ); + needs_help = (*scheduler->Operations.update_priority)( scheduler, thread); _Scheduler_Release_critical( scheduler, &scheduler_lock_context ); _Thread_State_release( thread, &state_lock_context ); @@ -216,7 +215,7 @@ static Thread_Control *change_priority_op( return needs_help; } -static void test_case_change_priority_op( +static void test_case_update_priority_op( Thread_Control *executing, Scheduler_SMP_Node *executing_node, Thread_Control *other, @@ -244,7 +243,7 @@ static void test_case_change_priority_op( } rtems_test_assert(executing_node->state == start_state); - needs_help = change_priority_op(executing, prio, prepend_it); + needs_help = update_priority_op(executing, prio, prepend_it); rtems_test_assert(executing_node->state == new_state); if (start_state != new_state) { @@ -269,7 +268,7 @@ static void test_case_change_priority_op( _Thread_Dispatch_enable( cpu_self ); } -static void test_change_priority_op(void) +static void test_update_priority_op(void) { rtems_status_code sc; rtems_id task_id; @@ -289,7 +288,7 @@ static void test_change_priority_op(void) for (i = 0; i < RTEMS_ARRAY_SIZE(states); ++i) { for (j = 0; j < RTEMS_ARRAY_SIZE(priorities); ++j) { for (k = 0; k < RTEMS_ARRAY_SIZE(prepend_it); ++k) { - test_case_change_priority_op( + test_case_update_priority_op( executing, executing_node, other, @@ -555,7 +554,7 @@ static void test_unblock_op(void) static void tests(void) { test_change_priority(); - test_change_priority_op(); + test_update_priority_op(); test_yield_op(); test_unblock_op(); } -- cgit v1.2.3