diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-11 10:21:57 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-12 13:24:40 +0200 |
commit | 4d76300ae524f798bf665f6c28dca420fd23a59c (patch) | |
tree | ae47fefc2924fac943537ed2854279ead765ef63 /cpukit/rtems/src/tasksetpriority.c | |
parent | rtems: Use thread state lock for signals (diff) | |
download | rtems-4d76300ae524f798bf665f6c28dca420fd23a59c.tar.bz2 |
rtems: Avoid Giant lock for some task operations
Avoid Giant lock for rtems_task_set_priority(), rtems_task_suspend() and
rtems_task_resume().
Update #2555.
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; } |