Changeset edcf89b in rtems


Ignore:
Timestamp:
Mar 27, 2015, 8:08:21 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
1461aba8
Parents:
342708b9
git-author:
Sebastian Huber <sebastian.huber@…> (03/27/15 20:08:21)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/08/15 09:48:15)
Message:

rtems: Atomically suspend/resume tasks

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/src/taskresume.c

    r342708b9 redcf89b  
    2828  Thread_Control          *the_thread;
    2929  Objects_Locations        location;
     30  States_Control           previous_state;
    3031
    3132  the_thread = _Thread_Get( id, &location );
     
    3334
    3435    case OBJECTS_LOCAL:
    35       if ( _States_Is_suspended( the_thread->current_state ) ) {
    36         _Thread_Resume( the_thread );
    37         _Objects_Put( &the_thread->Object );
    38         return RTEMS_SUCCESSFUL;
    39       }
     36      previous_state = _Thread_Clear_state( the_thread, STATES_SUSPENDED );
    4037      _Objects_Put( &the_thread->Object );
    41       return RTEMS_INCORRECT_STATE;
     38
     39      return _States_Is_suspended( previous_state ) ?
     40        RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE;
    4241
    4342#if defined(RTEMS_MULTIPROCESSING)
  • cpukit/rtems/src/tasksuspend.c

    r342708b9 redcf89b  
    2828  Thread_Control          *the_thread;
    2929  Objects_Locations        location;
     30  States_Control           previous_state;
    3031
    3132  the_thread = _Thread_Get( id, &location );
     
    3334
    3435    case OBJECTS_LOCAL:
    35       if ( !_States_Is_suspended( the_thread->current_state ) ) {
    36         _Thread_Suspend( the_thread );
    37         _Objects_Put( &the_thread->Object );
    38         return RTEMS_SUCCESSFUL;
    39       }
     36      previous_state = _Thread_Set_state( the_thread, STATES_SUSPENDED );
    4037      _Objects_Put( &the_thread->Object );
    41       return RTEMS_ALREADY_SUSPENDED;
     38
     39      return _States_Is_suspended( previous_state ) ?
     40        RTEMS_ALREADY_SUSPENDED : RTEMS_SUCCESSFUL;
    4241
    4342#if defined(RTEMS_MULTIPROCESSING)
  • cpukit/score/include/rtems/score/threadimpl.h

    r342708b9 redcf89b  
    355355  Priority_Control  new_priority
    356356);
    357 
    358 /**
    359  *  This routine updates the related suspend fields in the_thread
    360  *  control block to indicate the current nested level.
    361  */
    362 #define _Thread_Suspend( _the_thread ) \
    363         _Thread_Set_state( _the_thread, STATES_SUSPENDED )
    364 
    365 /**
    366  *  This routine updates the related suspend fields in the_thread
    367  *  control block to indicate the current nested level.  A force
    368  *  parameter of true will force a resume and clear the suspend count.
    369  */
    370 #define _Thread_Resume( _the_thread ) \
    371         _Thread_Clear_state( _the_thread, STATES_SUSPENDED )
    372357
    373358/**
  • testsuites/tmtests/tm26/task1.c

    r342708b9 redcf89b  
    175175#endif
    176176
    177   _Thread_Resume( thread );
     177  _Thread_Clear_state( thread, STATES_SUSPENDED );
    178178
    179179#if defined( PREVENT_SMP_ASSERT_FAILURES )
Note: See TracChangeset for help on using the changeset viewer.