Changeset 00815403 in rtems


Ignore:
Timestamp:
Aug 9, 2001, 8:46:12 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
33c31af7
Parents:
2082fe29
Message:

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

  • include/rtems/score/coremsg.h, inline/rtems/score/coremsg.inl, 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@…>.
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/ChangeLog

    r2082fe29 r00815403  
     1
     22001-08-09      Joel Sherrill <joel@OARcorp.com>
     3
     4        * include/rtems/score/coremsg.h, inline/rtems/score/coremsg.inl,
     5        src/coremsgsubmit.c: Unblocking message queue operations should
     6        NOT use _Thread_Executing for return status since it is permissible
     7        to invoke message send operations from an ISR.  This was reported
     8        by Suvrat Gupta <suvrat@utstar.com>.
    19
    2102000-05-25      Sergei Organov <osv@javad.ru>
  • c/src/exec/score/include/rtems/score/coremsg.h

    r2082fe29 r00815403  
    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

    r2082fe29 r00815403  
    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

    r2082fe29 r00815403  
    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}
  • cpukit/score/ChangeLog

    r2082fe29 r00815403  
     1
     22001-08-09      Joel Sherrill <joel@OARcorp.com>
     3
     4        * include/rtems/score/coremsg.h, inline/rtems/score/coremsg.inl,
     5        src/coremsgsubmit.c: Unblocking message queue operations should
     6        NOT use _Thread_Executing for return status since it is permissible
     7        to invoke message send operations from an ISR.  This was reported
     8        by Suvrat Gupta <suvrat@utstar.com>.
    19
    2102000-05-25      Sergei Organov <osv@javad.ru>
  • cpukit/score/include/rtems/score/coremsg.h

    r2082fe29 r00815403  
    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,
  • cpukit/score/inline/rtems/score/coremsg.inl

    r2082fe29 r00815403  
    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,
  • cpukit/score/src/coremsgsubmit.c

    r2082fe29 r00815403  
    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.