diff options
Diffstat (limited to 'cpukit/rtems/src/tasksetpriority.c')
-rw-r--r-- | cpukit/rtems/src/tasksetpriority.c | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/cpukit/rtems/src/tasksetpriority.c b/cpukit/rtems/src/tasksetpriority.c index c6b2dc0a46..d343935cf4 100644 --- a/cpukit/rtems/src/tasksetpriority.c +++ b/cpukit/rtems/src/tasksetpriority.c @@ -27,8 +27,9 @@ rtems_status_code rtems_task_set_priority( rtems_task_priority *old_priority ) { - Thread_Control *the_thread; - Objects_Locations location; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + Per_CPU_Control *cpu_self; if ( new_priority != RTEMS_CURRENT_PRIORITY && !_RTEMS_tasks_Priority_is_valid( new_priority ) ) @@ -37,39 +38,33 @@ rtems_status_code rtems_task_set_priority( if ( !old_priority ) return RTEMS_INVALID_ADDRESS; - the_thread = _Thread_Get( id, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - if ( new_priority != RTEMS_CURRENT_PRIORITY ) { - _Thread_Set_priority( - the_thread, - _RTEMS_tasks_Priority_to_Core( new_priority ), - old_priority, - false - ); - *old_priority = _RTEMS_tasks_Priority_from_Core( *old_priority ); - } else { - *old_priority = _RTEMS_tasks_Priority_from_Core( - the_thread->current_priority - ); - } - _Objects_Put( &the_thread->Object ); - return RTEMS_SUCCESSFUL; + the_thread = _Thread_Get_interrupt_disable( id, &lock_context ); + if ( the_thread == NULL ) { #if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: - _Thread_Executing->Wait.return_argument = old_priority; - return _RTEMS_tasks_MP_Send_request_packet( - RTEMS_TASKS_MP_SET_PRIORITY_REQUEST, - id, - new_priority - ); + return _RTEMS_tasks_MP_Set_priority( id, new_priority, old_priority ); +#else + return RTEMS_INVALID_ID; #endif + } + + cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); + _ISR_lock_ISR_enable( &lock_context ); - case OBJECTS_ERROR: - break; + if ( new_priority != RTEMS_CURRENT_PRIORITY ) { + _Thread_Set_priority( + the_thread, + _RTEMS_tasks_Priority_to_Core( new_priority ), + old_priority, + false + ); + *old_priority = _RTEMS_tasks_Priority_from_Core( *old_priority ); + } else { + *old_priority = _RTEMS_tasks_Priority_from_Core( + the_thread->current_priority + ); } - return RTEMS_INVALID_ID; + _Thread_Dispatch_enable( cpu_self ); + return RTEMS_SUCCESSFUL; } |