Changeset 3bb9542c in rtems


Ignore:
Timestamp:
Aug 9, 2001, 9:08:50 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Children:
256226b
Parents:
b748fff9
Message:

2001-08-09 Joel Sherrill <joel@…>

  • c/src/exec/itron/src/snd_mbx.c, c/src/exec/itron/src/tsnd_mbf.c c/src/exec/posix/src/mqueuesendsupp.c, c/src/exec/rtems/src/msgqsubmit.c, c/src/exec/score/include/rtems/score/coremsg.h, c/src/exec/score/inline/rtems/score/coremsg.inl, c/src/exec/score/src/coremsgsubmit.c: Unblocking message queue operations should NOT use _Thread_Executing for return status since it is permissible to invoke message send operations from an ISR. This was reported by Suvrat Gupta <suvrat@…>.
Location:
c/src/exec
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/itron/src/snd_mbx.c

    rb748fff9 r3bb9542c  
    3030  unsigned32                       message_priority;
    3131  void                            *message_contents;
     32  CORE_message_queue_Status        msg_status;
    3233
    3334  if ( !pk_msg )
     
    4748
    4849      message_contents = pk_msg;
    49       _CORE_message_queue_Submit(
     50      msg_status = _CORE_message_queue_Submit(
    5051        &the_mailbox->message_queue,
    5152        &message_contents,
     
    6162
    6263  _ITRON_return_errorno(
    63      _ITRON_Mailbox_Translate_core_message_queue_return_code(
    64           _Thread_Executing->Wait.return_code
    65      )
     64     _ITRON_Mailbox_Translate_core_message_queue_return_code( msg_status )
    6665  );
    6766}
  • c/src/exec/itron/src/tsnd_mbf.c

    rb748fff9 r3bb9542c  
    3434  Watchdog_Interval              interval;
    3535  boolean                        wait;
     36  CORE_message_queue_Status      msg_status;
    3637
    3738  if (msgsz <= 0 || !msg)
     
    5859    case OBJECTS_LOCAL:
    5960      /* XXX Submit needs to take into account blocking */
    60       _CORE_message_queue_Submit(
     61      msg_status = _CORE_message_queue_Submit(
    6162        &the_message_buffer->message_queue,
    6263        msg,
     
    7071      _Thread_Enable_dispatch();
    7172      return _ITRON_Message_buffer_Translate_core_message_buffer_return_code(
    72           _Thread_Executing->Wait.return_code
     73          msg_status
    7374      );
    7475    }
  • c/src/exec/posix/src/mqueuesendsupp.c

    rb748fff9 r3bb9542c  
    4545  register POSIX_Message_queue_Control *the_mq;
    4646  Objects_Locations                     location;
     47  CORE_message_queue_Status             msg_status;
    4748
    4849  /*
     
    7172      }
    7273
    73       _CORE_message_queue_Submit(
     74      msg_status = _CORE_message_queue_Submit(
    7475        &the_mq->Message_queue,
    7576        (void *) msg_ptr,
     
    8788
    8889      _Thread_Enable_dispatch();
    89       if ( !_Thread_Executing->Wait.return_code )
     90      if ( !msg_status )
    9091        return 0;
    9192
    9293      set_errno_and_return_minus_one(
    9394        _POSIX_Message_queue_Translate_core_message_queue_return_code(
    94           _Thread_Executing->Wait.return_code
     95          msg_status
    9596        )
    9697      );
  • c/src/exec/rtems/src/msgqsubmit.c

    rb748fff9 r3bb9542c  
    6262  register Message_queue_Control  *the_message_queue;
    6363  Objects_Locations                location;
     64  CORE_message_queue_Status        msg_status;
    6465
    6566  the_message_queue = _Message_queue_Get( id, &location );
     
    9899      switch ( submit_type ) {
    99100        case MESSAGE_QUEUE_SEND_REQUEST:
    100           _CORE_message_queue_Send(
     101          msg_status = _CORE_message_queue_Send(
    101102            &the_message_queue->message_queue,
    102103            buffer,
     
    113114          break;
    114115        case MESSAGE_QUEUE_URGENT_REQUEST:
    115           _CORE_message_queue_Urgent(
     116          msg_status = _CORE_message_queue_Urgent(
    116117            &the_message_queue->message_queue,
    117118            buffer,
     
    132133
    133134      _Thread_Enable_dispatch();
    134       return _Message_queue_Translate_core_message_queue_return_code(
    135         _Thread_Executing->Wait.return_code
    136       );
     135      return
     136        _Message_queue_Translate_core_message_queue_return_code( msg_status );
    137137         
    138138  }
  • c/src/exec/score/include/rtems/score/coremsg.h

    rb748fff9 r3bb9542c  
    240240 */
    241241 
    242 void _CORE_message_queue_Submit(
     242CORE_message_queue_Status _CORE_message_queue_Submit(
    243243  CORE_message_queue_Control                *the_message_queue,
    244244  void                                      *buffer,
  • c/src/exec/score/inline/rtems/score/coremsg.inl

    rb748fff9 r3bb9542c  
    2828 */
    2929 
    30 RTEMS_INLINE_ROUTINE void _CORE_message_queue_Send(
     30RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
    3131  CORE_message_queue_Control                *the_message_queue,
    3232  void                                      *buffer,
     
    3838)
    3939{
    40   _CORE_message_queue_Submit(
     40  return _CORE_message_queue_Submit(
    4141    the_message_queue,
    4242    buffer,
     
    6363 */
    6464 
    65 RTEMS_INLINE_ROUTINE void _CORE_message_queue_Urgent(
     65RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
    6666  CORE_message_queue_Control                *the_message_queue,
    6767  void                                      *buffer,
     
    7373)
    7474{
    75   _CORE_message_queue_Submit(
     75  return _CORE_message_queue_Submit(
    7676    the_message_queue,
    7777    buffer,
  • c/src/exec/score/src/coremsgsubmit.c

    rb748fff9 r3bb9542c  
    5454 */
    5555
    56 void _CORE_message_queue_Submit(
     56CORE_message_queue_Status _CORE_message_queue_Submit(
    5757  CORE_message_queue_Control                *the_message_queue,
    5858  void                                      *buffer,
     
    6868  CORE_message_queue_Buffer_control   *the_message;
    6969  Thread_Control                      *the_thread;
    70   Thread_Control                      *executing;
    71 
    72   _Thread_Executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    7370
    7471  if ( size > the_message_queue->maximum_message_size ) {
    75     _Thread_Executing->Wait.return_code =
    76        CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
    77     return;
     72    return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
    7873  }
    7974
     
    9792        (*api_message_queue_mp_support) ( the_thread, id );
    9893#endif
    99       return;
     94      return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    10095    }
    10196  }
     
    115110     *  NOTE: If the system is consistent, this error should never occur.
    116111     */
     112
    117113    if ( !the_message ) {
    118       _Thread_Executing->Wait.return_code =
    119           CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
    120       return;
     114      return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
    121115    }
    122116
     
    134128       submit_type
    135129    );
    136     return;
     130    return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    137131  }
    138132
     
    144138
    145139  if ( !wait ) {
    146     _Thread_Executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
    147     return;
     140    return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
    148141  }
    149142
    150   executing = _Thread_Executing;
     143  /*
     144   *  Do NOT block on a send if the caller is in an ISR.  It is
     145   *  deadly to block in an ISR.
     146   */
    151147
    152   _ISR_Disable( level );
    153   _Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
    154   executing->Wait.queue              = &the_message_queue->Wait_queue;
    155   executing->Wait.id                 = id;
    156   executing->Wait.return_argument    = (void *)buffer;
    157   executing->Wait.return_argument_1  = (void *)size;
    158   executing->Wait.count              = submit_type;
    159   _ISR_Enable( level );
     148  if ( _ISR_Is_in_progress() ) {
     149    return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
     150  }
    160151
    161   _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
     152  /*
     153   *  WARNING!! executing should NOT be used prior to this point.
     154   *  Thus the unusual choice to open a new scope and declare
     155   *  it as a variable.  Doing this emphasizes how dangerous it
     156   *  would be to use this variable prior to here.
     157   */
     158
     159  {
     160    Thread_Control  *executing = _Thread_Executing;
     161
     162    _ISR_Disable( level );
     163    _Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
     164    executing->Wait.queue              = &the_message_queue->Wait_queue;
     165    executing->Wait.id                 = id;
     166    executing->Wait.return_argument    = (void *)buffer;
     167    executing->Wait.return_argument_1  = (void *)size;
     168    executing->Wait.count              = submit_type;
     169    _ISR_Enable( level );
     170
     171    _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
     172  }
     173
     174  return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    162175}
Note: See TracChangeset for help on using the changeset viewer.