Changeset 7d6e94b in rtems


Ignore:
Timestamp:
Mar 4, 2015, 7:02:19 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
7183f1cd
Parents:
4c8a0ac
git-author:
Sebastian Huber <sebastian.huber@…> (03/04/15 07:02:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/05/15 10:36:45)
Message:

score: Implement fine-grained locking for events

Use the ISR lock of the thread object to protect the event state and
use the Giant lock only for the blocking operations.

Update #2273.

Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/Makefile.am

    r4c8a0ac r7d6e94b  
    212212librtems_a_SOURCES += src/eventsurrender.c
    213213librtems_a_SOURCES += src/eventtimeout.c
    214 librtems_a_SOURCES += src/eventdata.c
    215214librtems_a_SOURCES += src/systemeventsend.c
    216215librtems_a_SOURCES += src/systemeventreceive.c
  • cpukit/rtems/include/rtems/rtems/eventimpl.h

    r4c8a0ac r7d6e94b  
    3434
    3535/**
    36  *  This constant is defined to extern most of the time when using
    37  *  this header file.  However by defining it to nothing, the data
    38  *  declared in this header file can be instantiated.  This is done
    39  *  in a single per manager file.
    40  */
    41 #ifndef RTEMS_EVENT_EXTERN
    42 #define RTEMS_EVENT_EXTERN extern
    43 #endif
    44 
    45 /**
    4636 *  This constant is passed as the event_in to the
    4737 *  rtems_event_receive directive to determine which events are pending.
     
    5444 */
    5545#define EVENT_SETS_NONE_PENDING 0
    56 
    57 RTEMS_EVENT_EXTERN Thread_blocking_operation_States _Event_Sync_state;
    58 
    59 RTEMS_EVENT_EXTERN Thread_blocking_operation_States _System_event_Sync_state;
    6046
    6147/**
     
    7258
    7359void _Event_Seize(
    74   rtems_event_set                   event_in,
    75   rtems_option                      option_set,
    76   rtems_interval                    ticks,
    77   rtems_event_set                  *event_out,
    78   Thread_Control                   *executing,
    79   Event_Control                    *event,
    80   Thread_blocking_operation_States *sync_state,
    81   States_Control                    wait_state
     60  rtems_event_set    event_in,
     61  rtems_option       option_set,
     62  rtems_interval     ticks,
     63  rtems_event_set   *event_out,
     64  Thread_Control    *executing,
     65  Event_Control     *event,
     66  Thread_Wait_flags  wait_class,
     67  States_Control     block_state,
     68  ISR_lock_Context  *lock_context
    8269);
    8370
    84 /**
    85  *  @brief Surrender Event
    86  *
    87  *  - INTERRUPT LATENCY:
    88  *    + before flash
    89  *    + after flash
    90  *    + check sync
    91  */
    9271void _Event_Surrender(
    93   Thread_Control                   *the_thread,
    94   rtems_event_set                   event_in,
    95   Event_Control                    *event,
    96   Thread_blocking_operation_States *sync_state,
    97   States_Control                    wait_state
     72  Thread_Control    *the_thread,
     73  rtems_event_set    event_in,
     74  Event_Control     *event,
     75  Thread_Wait_flags  wait_class,
     76  ISR_lock_Context  *lock_context
    9877);
    9978
  • cpukit/rtems/src/event.c

    r4c8a0ac r7d6e94b  
    2323void _Event_Manager_initialization( void )
    2424{
    25   _Event_Sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
    26   _System_event_Sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
    27 
    2825  /*
    2926   *  Register the MP Process Packet routine.
  • cpukit/rtems/src/eventreceive.c

    r4c8a0ac r7d6e94b  
    2222#include <rtems/rtems/tasks.h>
    2323#include <rtems/score/statesimpl.h>
    24 #include <rtems/score/threaddispatch.h>
     24#include <rtems/score/threadimpl.h>
    2525
    2626rtems_status_code rtems_event_receive(
     
    3434
    3535  if ( event_out != NULL ) {
    36     Thread_Control    *executing = _Thread_Get_executing();
     36    ISR_lock_Context   lock_context;
     37    Thread_Control    *executing = _Thread_Acquire_executing( &lock_context );
    3738    RTEMS_API_Control *api = executing->API_Extensions[ THREAD_API_RTEMS ];
    3839    Event_Control     *event = &api->Event;
    3940
    4041    if ( !_Event_sets_Is_empty( event_in ) ) {
    41       _Thread_Disable_dispatch();
    4242      _Event_Seize(
    4343        event_in,
     
    4747        executing,
    4848        event,
    49         &_Event_Sync_state,
    50         STATES_WAITING_FOR_EVENT
     49        THREAD_WAIT_CLASS_EVENT,
     50        STATES_WAITING_FOR_EVENT,
     51        &lock_context
    5152      );
    52       _Thread_Enable_dispatch();
    5353
    5454      sc = executing->Wait.return_code;
    5555    } else {
    5656      *event_out = event->pending_events;
     57      _Objects_Release_and_ISR_enable( &executing->Object, &lock_context );
    5758      sc = RTEMS_SUCCESSFUL;
    5859    }
  • cpukit/rtems/src/eventseize.c

    r4c8a0ac r7d6e94b  
    3232
    3333void _Event_Seize(
    34   rtems_event_set                   event_in,
    35   rtems_option                      option_set,
    36   rtems_interval                    ticks,
    37   rtems_event_set                  *event_out,
    38   Thread_Control                   *executing,
    39   Event_Control                    *event,
    40   Thread_blocking_operation_States *sync_state,
    41   States_Control                    wait_state
     34  rtems_event_set    event_in,
     35  rtems_option       option_set,
     36  rtems_interval     ticks,
     37  rtems_event_set   *event_out,
     38  Thread_Control    *executing,
     39  Event_Control     *event,
     40  Thread_Wait_flags  wait_class,
     41  States_Control     block_state,
     42  ISR_lock_Context  *lock_context
    4243)
    4344{
    44   rtems_event_set                  seized_events;
    45   rtems_event_set                  pending_events;
    46   ISR_Level                        level;
    47   Thread_blocking_operation_States current_sync_state;
     45  rtems_event_set    seized_events;
     46  rtems_event_set    pending_events;
     47  bool               success;
     48  Thread_Wait_flags  intend_to_block;
     49  Per_CPU_Control   *cpu_self;
    4850
    4951  executing->Wait.return_code = RTEMS_SUCCESSFUL;
    5052
    51   _ISR_Disable( level );
    5253  pending_events = event->pending_events;
    5354  seized_events  = _Event_sets_Get( pending_events, event_in );
     
    5758    event->pending_events =
    5859      _Event_sets_Clear( pending_events, seized_events );
    59     _ISR_Enable( level );
     60    _Objects_Release_and_ISR_enable( &executing->Object, lock_context );
    6061    *event_out = seized_events;
    6162    return;
     
    6364
    6465  if ( _Options_Is_no_wait( option_set ) ) {
    65     _ISR_Enable( level );
     66    _Objects_Release_and_ISR_enable( &executing->Object, lock_context );
    6667    executing->Wait.return_code = RTEMS_UNSATISFIED;
    6768    *event_out = seized_events;
    6869    return;
    6970  }
     71
     72  intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK;
    7073
    7174  /*
     
    7780   *        issue but better safe than sorry.
    7881   */
    79   executing->Wait.option            = option_set;
    80   executing->Wait.count             = event_in;
    81   executing->Wait.return_argument   = event_out;
     82  executing->Wait.option          = option_set;
     83  executing->Wait.count           = event_in;
     84  executing->Wait.return_argument = event_out;
     85  _Thread_Wait_flags_set( executing, intend_to_block );
    8286
    83   *sync_state = THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    84 
    85   _ISR_Enable( level );
     87  cpu_self = _Objects_Release_and_thread_dispatch_disable(
     88    &executing->Object,
     89    lock_context
     90  );
     91  _Giant_Acquire( cpu_self );
    8692
    8793  if ( ticks ) {
     
    9096      _Event_Timeout,
    9197      executing->Object.id,
    92       sync_state
     98      NULL
    9399    );
    94100    _Watchdog_Insert_ticks( &executing->Timer, ticks );
    95101  }
    96102
    97   _Thread_Set_state( executing, wait_state );
     103  _Thread_Set_state( executing, block_state );
    98104
    99   _ISR_Disable( level );
    100 
    101   current_sync_state = *sync_state;
    102   *sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
    103   if ( current_sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
    104     _ISR_Enable( level );
    105     return;
     105  success = _Thread_Wait_flags_try_change(
     106    executing,
     107    intend_to_block,
     108    wait_class | THREAD_WAIT_STATE_BLOCKED
     109  );
     110  if ( !success ) {
     111    _Watchdog_Remove( &executing->Timer );
     112    _Thread_Unblock( executing );
    106113  }
    107114
    108   /*
    109    *  An interrupt completed the thread's blocking request.
    110    *  The blocking thread was satisfied by an ISR or timed out.
    111    *
    112    *  WARNING! Entering with interrupts disabled and returning with interrupts
    113    *  enabled!
    114    */
    115   _Thread_blocking_operation_Cancel( current_sync_state, executing, level );
     115  _Giant_Release( cpu_self );
     116  _Thread_Dispatch_enable( cpu_self );
    116117}
  • cpukit/rtems/src/eventsend.c

    r4c8a0ac r7d6e94b  
    3232  Objects_Locations  location;
    3333  RTEMS_API_Control *api;
     34  ISR_lock_Context   lock_context;
    3435
    35   thread = _Thread_Get( id, &location );
     36  thread = _Thread_Acquire( id, &location, &lock_context );
    3637  switch ( location ) {
    3738    case OBJECTS_LOCAL:
     
    4142        event_in,
    4243        &api->Event,
    43         &_Event_Sync_state,
    44         STATES_WAITING_FOR_EVENT
     44        THREAD_WAIT_CLASS_EVENT,
     45        &lock_context
    4546      );
    46       _Objects_Put( &thread->Object );
    4747      sc = RTEMS_SUCCESSFUL;
    4848      break;
  • cpukit/rtems/src/eventsurrender.c

    r4c8a0ac r7d6e94b  
    2424#include <rtems/score/watchdogimpl.h>
    2525
    26 void _Event_Surrender(
    27   Thread_Control                   *the_thread,
    28   rtems_event_set                   event_in,
    29   Event_Control                    *event,
    30   Thread_blocking_operation_States *sync_state,
    31   States_Control                    wait_state
     26static void _Event_Satisfy(
     27  Thread_Control  *the_thread,
     28  Event_Control   *event,
     29  rtems_event_set  pending_events,
     30  rtems_event_set  seized_events
    3231)
    3332{
    34   ISR_Level       level;
    35   rtems_event_set pending_events;
     33  event->pending_events = _Event_sets_Clear( pending_events, seized_events );
     34  *(rtems_event_set *) the_thread->Wait.return_argument = seized_events;
     35}
     36
     37static bool _Event_Is_satisfied(
     38  const Thread_Control *the_thread,
     39  rtems_event_set       pending_events,
     40  rtems_event_set      *seized_events
     41)
     42{
     43  rtems_option    option_set;
    3644  rtems_event_set event_condition;
    37   rtems_event_set seized_events;
    38   rtems_option    option_set;
    3945
    4046  option_set = the_thread->Wait.option;
     47  event_condition = the_thread->Wait.count;
     48  *seized_events = _Event_sets_Get( pending_events, event_condition );
    4149
    42   _ISR_Disable( level );
     50  return !_Event_sets_Is_empty( *seized_events )
     51    && ( *seized_events == event_condition || _Options_Is_any( option_set ) );
     52}
     53
     54void _Event_Surrender(
     55  Thread_Control    *the_thread,
     56  rtems_event_set    event_in,
     57  Event_Control     *event,
     58  Thread_Wait_flags  wait_class,
     59  ISR_lock_Context  *lock_context
     60)
     61{
     62  rtems_event_set   pending_events;
     63  rtems_event_set   seized_events;
     64  Thread_Wait_flags wait_flags;
     65  bool              unblock;
     66
    4367  _Event_sets_Post( event_in, &event->pending_events );
    44   pending_events  = event->pending_events;
     68  pending_events = event->pending_events;
    4569
    46   /*
    47    * At this point the event condition is a speculative quantity.  Later state
    48    * checks will show if the thread actually waits for an event.
    49    */
    50   event_condition = the_thread->Wait.count;
    51 
    52   seized_events = _Event_sets_Get( pending_events, event_condition );
     70  wait_flags = _Thread_Wait_flags_get( the_thread );
    5371
    5472  if (
    55     !_Event_sets_Is_empty( seized_events )
    56       && ( seized_events == event_condition || _Options_Is_any( option_set ) )
     73    ( wait_flags & THREAD_WAIT_CLASS_MASK ) == wait_class
     74      && _Event_Is_satisfied( the_thread, pending_events, &seized_events )
    5775  ) {
    58     /*
    59      *  If we are sending to the executing thread, then we have a critical
    60      *  section issue to deal with.  The entity sending to the executing thread
    61      *  can be either the executing thread or an ISR.  In case it is the
    62      *  executing thread, then the blocking operation state is not equal to
    63      *  THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED.
    64      */
    65     if ( _Thread_Is_executing( the_thread ) &&
    66          *sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
    67       event->pending_events = _Event_sets_Clear(
    68         pending_events,
    69         seized_events
     76    Thread_Wait_flags intend_to_block;
     77    Thread_Wait_flags blocked;
     78    bool success;
     79
     80    intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK;
     81    blocked = wait_class | THREAD_WAIT_STATE_BLOCKED;
     82
     83    success = _Thread_Wait_flags_try_change_critical(
     84      the_thread,
     85      intend_to_block,
     86      wait_class | THREAD_WAIT_STATE_INTERRUPT_SATISFIED
     87    );
     88    if ( success ) {
     89      _Event_Satisfy( the_thread, event, pending_events, seized_events );
     90      unblock = false;
     91    } else if ( _Thread_Wait_flags_get( the_thread ) == blocked ) {
     92      _Event_Satisfy( the_thread, event, pending_events, seized_events );
     93      _Thread_Wait_flags_set(
     94        the_thread,
     95        wait_class | THREAD_WAIT_STATE_SATISFIED
    7096      );
    71       the_thread->Wait.count = 0;
    72       *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
    73       *sync_state = THREAD_BLOCKING_OPERATION_SATISFIED;
    74     } else if ( _States_Are_set( the_thread->current_state, wait_state ) ) {
    75       event->pending_events = _Event_sets_Clear(
    76         pending_events,
    77         seized_events
    78       );
    79       the_thread->Wait.count = 0;
    80       *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
     97      unblock = true;
     98    } else {
     99      unblock = false;
     100    }
     101  } else {
     102    unblock = false;
     103  }
    81104
    82       _ISR_Flash( level );
     105  if ( unblock ) {
     106    Per_CPU_Control *cpu_self;
    83107
    84       if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
    85         _ISR_Enable( level );
    86         _Thread_Unblock( the_thread );
    87       } else {
    88         _Watchdog_Deactivate( &the_thread->Timer );
    89         _ISR_Enable( level );
    90         (void) _Watchdog_Remove( &the_thread->Timer );
    91         _Thread_Unblock( the_thread );
    92       }
    93       return;
    94     }
     108    cpu_self = _Objects_Release_and_thread_dispatch_disable(
     109      &the_thread->Object,
     110      lock_context
     111    );
     112    _Giant_Acquire( cpu_self );
     113
     114    _Watchdog_Remove( &the_thread->Timer );
     115    _Thread_Unblock( the_thread );
     116
     117    _Giant_Release( cpu_self );
     118    _Thread_Dispatch_enable( cpu_self );
     119  } else {
     120    _Objects_Release_and_ISR_enable( &the_thread->Object, lock_context );
    95121  }
    96   _ISR_Enable( level );
    97122}
  • cpukit/rtems/src/eventtimeout.c

    r4c8a0ac r7d6e94b  
    2727)
    2828{
    29   Thread_Control                   *the_thread;
    30   Objects_Locations                 location;
    31   ISR_Level                         level;
    32   Thread_blocking_operation_States *sync_state;
     29  Thread_Control    *the_thread;
     30  Objects_Locations  location;
     31  ISR_lock_Context   lock_context;
     32  Thread_Wait_flags  wait_flags;
     33  Thread_Wait_flags  wait_class;
     34  Thread_Wait_flags  intend_to_block;
     35  Thread_Wait_flags  blocked;
     36  bool               success;
     37  bool               unblock;
    3338
    34   sync_state = arg;
     39  the_thread = _Thread_Acquire( id, &location, &lock_context );
     40  switch ( location ) {
     41    case OBJECTS_LOCAL:
     42      wait_flags = _Thread_Wait_flags_get( the_thread );
     43      wait_class = wait_flags & THREAD_WAIT_CLASS_MASK;
     44      intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK;
     45      blocked = wait_class | THREAD_WAIT_STATE_BLOCKED;
     46      success = _Thread_Wait_flags_try_change_critical(
     47        the_thread,
     48        intend_to_block,
     49        wait_class | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT
     50      );
    3551
    36   the_thread = _Thread_Get( id, &location );
    37   switch ( location ) {
     52      if ( success ) {
     53        the_thread->Wait.return_code = RTEMS_TIMEOUT;
     54        unblock = false;
     55      } else if ( _Thread_Wait_flags_get( the_thread ) == blocked ) {
     56        the_thread->Wait.return_code = RTEMS_TIMEOUT;
     57        _Thread_Wait_flags_set(
     58          the_thread,
     59          wait_class | THREAD_WAIT_STATE_TIMEOUT
     60        );
     61        unblock = true;
     62      } else {
     63        unblock = false;
     64      }
    3865
    39     case OBJECTS_LOCAL:
     66      if ( unblock ) {
     67        Per_CPU_Control *cpu_self;
    4068
    41       /*
    42        *  If the event manager is not synchronized, then it is either
    43        *  "nothing happened", "timeout", or "satisfied".   If the_thread
    44        *  is the executing thread, then it is in the process of blocking
    45        *  and it is the thread which is responsible for the synchronization
    46        *  process.
    47        *
    48        *  If it is not satisfied, then it is "nothing happened" and
    49        *  this is the "timeout" transition.  After a request is satisfied,
    50        *  a timeout is not allowed to occur.
    51        */
    52       _ISR_Disable( level );
    53         /*
    54          * Verify that the thread is still waiting for the event condition.
    55          * This test is necessary to avoid state corruption if the timeout
    56          * happens after the event condition is satisfied in
    57          * _Event_Surrender().  A satisfied event condition is indicated with
    58          * count set to zero.
    59          */
    60         if ( !the_thread->Wait.count ) {
    61           _ISR_Enable( level );
    62           _Objects_Put_without_thread_dispatch( &the_thread->Object );
    63           return;
    64         }
     69        cpu_self = _Objects_Release_and_thread_dispatch_disable(
     70          &the_thread->Object,
     71          &lock_context
     72        );
     73        _Giant_Acquire( cpu_self );
    6574
    66         the_thread->Wait.count = 0;
    67         if ( _Thread_Is_executing( the_thread ) ) {
    68           if ( *sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED )
    69             *sync_state = THREAD_BLOCKING_OPERATION_TIMEOUT;
    70         }
     75        _Thread_Unblock( the_thread );
    7176
    72         the_thread->Wait.return_code = RTEMS_TIMEOUT;
    73       _ISR_Enable( level );
    74       _Thread_Unblock( the_thread );
    75       _Objects_Put_without_thread_dispatch( &the_thread->Object );
     77        _Giant_Release( cpu_self );
     78        _Thread_Dispatch_enable( cpu_self );
     79      } else {
     80        _Objects_Release_and_ISR_enable( &the_thread->Object, &lock_context );
     81      }
     82
    7683      break;
    77 
    7884#if defined(RTEMS_MULTIPROCESSING)
    7985    case OBJECTS_REMOTE:  /* impossible */
  • cpukit/rtems/src/systemeventreceive.c

    r4c8a0ac r7d6e94b  
    2828#include <rtems/rtems/tasks.h>
    2929#include <rtems/score/statesimpl.h>
    30 #include <rtems/score/threaddispatch.h>
     30#include <rtems/score/threadimpl.h>
    3131
    3232rtems_status_code rtems_event_system_receive(
     
    4040
    4141  if ( event_out != NULL ) {
    42     Thread_Control    *executing = _Thread_Get_executing();
     42    ISR_lock_Context   lock_context;
     43    Thread_Control    *executing = _Thread_Acquire_executing( &lock_context );
    4344    RTEMS_API_Control *api = executing->API_Extensions[ THREAD_API_RTEMS ];
    4445    Event_Control     *event = &api->System_event;
    4546
    4647    if ( !_Event_sets_Is_empty( event_in ) ) {
    47       _Thread_Disable_dispatch();
    4848      _Event_Seize(
    4949        event_in,
     
    5353        executing,
    5454        event,
    55         &_System_event_Sync_state,
    56         STATES_WAITING_FOR_SYSTEM_EVENT
     55        THREAD_WAIT_CLASS_SYSTEM_EVENT,
     56        STATES_WAITING_FOR_SYSTEM_EVENT,
     57        &lock_context
    5758      );
    58       _Thread_Enable_dispatch();
    5959
    6060      sc = executing->Wait.return_code;
    6161    } else {
    6262      *event_out = event->pending_events;
     63      _Objects_Release_and_ISR_enable( &executing->Object, &lock_context );
    6364      sc = RTEMS_SUCCESSFUL;
    6465    }
  • cpukit/rtems/src/systemeventsend.c

    r4c8a0ac r7d6e94b  
    3838  Objects_Locations  location;
    3939  RTEMS_API_Control *api;
     40  ISR_lock_Context   lock_context;
    4041
    41   thread = _Thread_Get( id, &location );
     42  thread = _Thread_Acquire( id, &location, &lock_context );
    4243  switch ( location ) {
    4344    case OBJECTS_LOCAL:
     
    4748        event_in,
    4849        &api->System_event,
    49         &_System_event_Sync_state,
    50         STATES_WAITING_FOR_SYSTEM_EVENT
     50        THREAD_WAIT_CLASS_SYSTEM_EVENT,
     51        &lock_context
    5152      );
    52       _Objects_Put( &thread->Object );
    5353      sc = RTEMS_SUCCESSFUL;
    5454      break;
  • cpukit/rtems/src/tasks.c

    r4c8a0ac r7d6e94b  
    5555  api = created->API_Extensions[ THREAD_API_RTEMS ];
    5656
    57   _Event_Initialize( &api->Event );
    58   _Event_Initialize( &api->System_event );
    5957  _ASR_Create( &api->Signal );
    6058  _Thread_Action_initialize( &api->Signal_action, _Signal_Action_handler );
  • testsuites/sptests/spintrcritical10/init.c

    r4c8a0ac r7d6e94b  
    1717#include <intrcritical.h>
    1818
     19#include <rtems/score/threadimpl.h>
    1920#include <rtems/rtems/eventimpl.h>
    2021
     
    3536} test_context;
    3637
     38static bool blocks_for_event(Thread_Wait_flags flags)
     39{
     40  return flags == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTEND_TO_BLOCK)
     41    || flags == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_BLOCKED);
     42}
     43
     44static bool interrupts_blocking_op(Thread_Wait_flags flags)
     45{
     46  return
     47    flags == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTEND_TO_BLOCK);
     48}
     49
    3750static void any_satisfy_before_timeout(rtems_id timer, void *arg)
    3851{
     
    4053  test_context *ctx = arg;
    4154  const Thread_Control *thread = ctx->thread;
    42 
    43   if (thread->Wait.count != 0) {
    44     ctx->hit = _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    45 
    46     rtems_test_assert(thread->Wait.count == EVENTS);
     55  Thread_Wait_flags flags = _Thread_Wait_flags_get(thread);
     56
     57  if (blocks_for_event(flags)) {
     58    ctx->hit = interrupts_blocking_op(flags);
     59
    4760    rtems_test_assert(
    4861      *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
     
    5366    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    5467
    55     rtems_test_assert(thread->Wait.count == 0);
    5668    rtems_test_assert(
    5769      *(rtems_event_set *) thread->Wait.return_argument == GREEN
     
    6274    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    6375
    64     rtems_test_assert(thread->Wait.count == 0);
    6576    rtems_test_assert(
    6677      *(rtems_event_set *) thread->Wait.return_argument == GREEN
     
    6879    rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
    6980
    70     _Event_Timeout(thread->Object.id, &_Event_Sync_state);
    71 
    72     rtems_test_assert(thread->Wait.count == 0);
     81    _Event_Timeout(thread->Object.id, NULL);
     82
    7383    rtems_test_assert(
    7484      *(rtems_event_set *) thread->Wait.return_argument == GREEN
     
    7888    if (ctx->hit) {
    7989      rtems_test_assert(
    80         _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED
     90        _Thread_Wait_flags_get(thread)
     91          == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_SATISFIED)
    8192      );
    8293    }
     94
     95    rtems_test_assert(thread->Wait.count == EVENTS);
    8396  }
    8497
     
    116129
    117130  ctx->hit = false;
    118   ctx->thread->Wait.count = 0;
    119131
    120132  sc = rtems_timer_fire_after(ctx->timer, 1, any_satisfy_before_timeout, ctx);
     
    138150  test_context *ctx = arg;
    139151  const Thread_Control *thread = ctx->thread;
    140 
    141   if (thread->Wait.count != 0) {
    142     ctx->hit = _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    143 
    144     rtems_test_assert(thread->Wait.count == EVENTS);
     152  Thread_Wait_flags flags = _Thread_Wait_flags_get(thread);
     153
     154  if (blocks_for_event(flags)) {
     155    ctx->hit = interrupts_blocking_op(flags);
     156
    145157    rtems_test_assert(
    146158      *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
     
    151163    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    152164
    153     rtems_test_assert(thread->Wait.count == EVENTS);
    154165    rtems_test_assert(
    155166      *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
     
    160171    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    161172
    162     rtems_test_assert(thread->Wait.count == 0);
    163173    rtems_test_assert(
    164174      *(rtems_event_set *) thread->Wait.return_argument == EVENTS
     
    166176    rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
    167177
    168     _Event_Timeout(thread->Object.id, &_Event_Sync_state);
    169 
    170     rtems_test_assert(thread->Wait.count == 0);
     178    _Event_Timeout(thread->Object.id, NULL);
     179
    171180    rtems_test_assert(
    172181      *(rtems_event_set *) thread->Wait.return_argument == EVENTS
     
    176185    if (ctx->hit) {
    177186      rtems_test_assert(
    178         _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED
     187        _Thread_Wait_flags_get(thread)
     188          == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_SATISFIED)
    179189      );
    180190    }
     191
     192    rtems_test_assert(thread->Wait.count == EVENTS);
    181193  }
    182194
     
    209221
    210222  ctx->hit = false;
    211   ctx->thread->Wait.count = 0;
    212223
    213224  sc = rtems_timer_fire_after(ctx->timer, 1, all_satisfy_before_timeout, ctx);
     
    231242  test_context *ctx = arg;
    232243  const Thread_Control *thread = ctx->thread;
    233 
    234   if (thread->Wait.count != 0) {
    235     ctx->hit =
    236       _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    237 
    238     rtems_test_assert(thread->Wait.count == EVENTS);
    239     rtems_test_assert(
    240       *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
    241     );
    242     rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
    243 
    244     _Event_Timeout(thread->Object.id, &_Event_Sync_state);
    245 
    246     rtems_test_assert(thread->Wait.count == 0);
     244  Thread_Wait_flags flags = _Thread_Wait_flags_get(thread);
     245
     246  if (blocks_for_event(flags)) {
     247    ctx->hit = interrupts_blocking_op(flags);
     248
     249    rtems_test_assert(
     250      *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
     251    );
     252    rtems_test_assert(thread->Wait.return_code == RTEMS_SUCCESSFUL);
     253
     254    _Event_Timeout(thread->Object.id, NULL);
     255
    247256    rtems_test_assert(
    248257      *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
     
    253262    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    254263
    255     rtems_test_assert(thread->Wait.count == 0);
    256264    rtems_test_assert(
    257265      *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF
     
    261269    if (ctx->hit) {
    262270      rtems_test_assert(
    263         _Event_Sync_state == THREAD_BLOCKING_OPERATION_TIMEOUT
     271        _Thread_Wait_flags_get(thread)
     272          == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT)
    264273      );
    265274    }
     275
     276    rtems_test_assert(thread->Wait.count == EVENTS);
    266277  }
    267278
     
    299310
    300311  ctx->hit = false;
    301   ctx->thread->Wait.count = 0;
    302312
    303313  sc = rtems_timer_fire_after(ctx->timer, 1, timeout_before_satisfied, ctx);
  • testsuites/sptests/spintrcritical21/init.c

    r4c8a0ac r7d6e94b  
    1919#include <intrcritical.h>
    2020
     21#include <rtems/score/threadimpl.h>
    2122#include <rtems/rtems/eventimpl.h>
    2223
     
    3536static rtems_id main_task;
    3637
     38static Thread_Control *main_thread;
     39
    3740static rtems_id other_task;
     41
     42static bool is_case_hit( void )
     43{
     44  return _Thread_Wait_flags_get( main_thread)
     45    == ( THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTEND_TO_BLOCK );
     46}
    3847
    3948static rtems_timer_service_routine test_event_from_isr(
     
    4453  rtems_status_code     status;
    4554
    46   if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
     55  if ( is_case_hit() ) {
    4756    /*
    4857     *  This event send hits the critical section but sends to
     
    8594  rtems_status_code     status;
    8695
    87   if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
     96  if ( is_case_hit() ) {
    8897    /*
    8998     *  We want to catch the task while it is blocking.  Otherwise
     
    118127
    119128  main_task = rtems_task_self();
     129  main_thread = _Thread_Get_executing();
    120130
    121131  status = rtems_task_create(
  • testsuites/sptests/spsize/size.c

    r4c8a0ac r7d6e94b  
    268268
    269269/*dpmemimpl.h*/ (sizeof _Dual_ported_memory_Information)  +
    270 
    271 /*eventimpl.h*/ (sizeof _Event_Sync_state)                +
    272270
    273271#if defined(RTEMS_MULTIPROCESSING)
Note: See TracChangeset for help on using the changeset viewer.