rtems: Atomically suspend/resume tasks

This commit is contained in:
Sebastian Huber
2015-04-08 11:48:15 +02:00
parent 342708b983
commit edcf89b6f2
4 changed files with 11 additions and 28 deletions
+5 -6
View File
@@ -27,18 +27,17 @@ rtems_status_code rtems_task_resume(
{
Thread_Control *the_thread;
Objects_Locations location;
States_Control previous_state;
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_LOCAL:
if ( _States_Is_suspended( the_thread->current_state ) ) {
_Thread_Resume( the_thread );
_Objects_Put( &the_thread->Object );
return RTEMS_SUCCESSFUL;
}
previous_state = _Thread_Clear_state( the_thread, STATES_SUSPENDED );
_Objects_Put( &the_thread->Object );
return RTEMS_INCORRECT_STATE;
return _States_Is_suspended( previous_state ) ?
RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
+5 -6
View File
@@ -27,18 +27,17 @@ rtems_status_code rtems_task_suspend(
{
Thread_Control *the_thread;
Objects_Locations location;
States_Control previous_state;
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_LOCAL:
if ( !_States_Is_suspended( the_thread->current_state ) ) {
_Thread_Suspend( the_thread );
_Objects_Put( &the_thread->Object );
return RTEMS_SUCCESSFUL;
}
previous_state = _Thread_Set_state( the_thread, STATES_SUSPENDED );
_Objects_Put( &the_thread->Object );
return RTEMS_ALREADY_SUSPENDED;
return _States_Is_suspended( previous_state ) ?
RTEMS_ALREADY_SUSPENDED : RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
@@ -355,21 +355,6 @@ void _Thread_Set_priority(
Priority_Control new_priority
);
/**
* This routine updates the related suspend fields in the_thread
* control block to indicate the current nested level.
*/
#define _Thread_Suspend( _the_thread ) \
_Thread_Set_state( _the_thread, STATES_SUSPENDED )
/**
* This routine updates the related suspend fields in the_thread
* control block to indicate the current nested level. A force
* parameter of true will force a resume and clear the suspend count.
*/
#define _Thread_Resume( _the_thread ) \
_Thread_Clear_state( _the_thread, STATES_SUSPENDED )
/**
* @brief Maps thread Id to a TCB pointer.
*
+1 -1
View File
@@ -174,7 +174,7 @@ static void thread_resume( Thread_Control *thread )
_Thread_Disable_dispatch();
#endif
_Thread_Resume( thread );
_Thread_Clear_state( thread, STATES_SUSPENDED );
#if defined( PREVENT_SMP_ASSERT_FAILURES )
_Thread_Unnest_dispatch();