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/tasksuspend.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/tasksuspend.c')
-rw-r--r-- | cpukit/rtems/src/tasksuspend.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/cpukit/rtems/src/tasksuspend.c b/cpukit/rtems/src/tasksuspend.c index 6b6616103e..bd9b89a2af 100644 --- a/cpukit/rtems/src/tasksuspend.c +++ b/cpukit/rtems/src/tasksuspend.c @@ -25,32 +25,27 @@ rtems_status_code rtems_task_suspend( rtems_id id ) { - Thread_Control *the_thread; - Objects_Locations location; - States_Control previous_state; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + Per_CPU_Control *cpu_self; + States_Control previous_state; - the_thread = _Thread_Get( id, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - previous_state = _Thread_Set_state( the_thread, STATES_SUSPENDED ); - _Objects_Put( &the_thread->Object ); - - return _States_Is_suspended( previous_state ) ? - RTEMS_ALREADY_SUSPENDED : RTEMS_SUCCESSFUL; + the_thread = _Thread_Get_interrupt_disable( id, &lock_context ); + if ( the_thread == NULL ) { #if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: - return _RTEMS_tasks_MP_Send_request_packet( - RTEMS_TASKS_MP_SUSPEND_REQUEST, - id, - 0 /* Not used */ - ); + return _RTEMS_tasks_MP_Suspend( id ); +#else + return RTEMS_INVALID_ID; #endif - - case OBJECTS_ERROR: - break; } - return RTEMS_INVALID_ID; + cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); + _ISR_lock_ISR_enable( &lock_context ); + + previous_state = _Thread_Set_state( the_thread, STATES_SUSPENDED ); + + _Thread_Dispatch_enable( cpu_self ); + return _States_Is_suspended( previous_state ) ? + RTEMS_ALREADY_SUSPENDED : RTEMS_SUCCESSFUL; } |