Changeset 507d382 in rtems for cpukit/score/src/coremsgsubmit.c


Ignore:
Timestamp:
Sep 11, 2009, 8:00:30 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 5, master
Children:
5a6d25fc
Parents:
b094233
Message:

2009-09-11 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/coremsg.h, score/inline/rtems/score/coremsg.inl, score/src/coremsg.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/objectnametoidstring.c: Disable the Core Message Queue features of notification, priority messages, and blocking sends when no API requires them.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/coremsgsubmit.c

    rb094233 r507d382  
    88 *  via messages passed to queue objects.
    99 *
    10  *  COPYRIGHT (c) 1989-1999.
     10 *  COPYRIGHT (c) 1989-2009.
    1111 *  On-Line Applications Research Corporation (OAR).
    1212 *
     
    7070)
    7171{
    72   ISR_Level                            level;
    7372  CORE_message_queue_Buffer_control   *the_message;
    7473  Thread_Control                      *the_thread;
     
    8180   *  Is there a thread currently waiting on this message queue?
    8281   */
    83 
    8482  if ( the_message_queue->number_of_pending_messages == 0 ) {
    8583    the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
     
    105103   *  queue the message up for a future receive.
    106104   */
    107 
    108105  if ( the_message_queue->number_of_pending_messages <
    109106       the_message_queue->maximum_pending_messages ) {
     
    127124    );
    128125    the_message->Contents.size = size;
    129     the_message->priority  = submit_type;
     126    #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     127      the_message->priority  = submit_type;
     128    #endif
    130129
    131130    _CORE_message_queue_Insert_message(
     
    137136  }
    138137
    139   /*
    140    *  No message buffers were available so we may need to return an
    141    *  overflow error or block the sender until the message is placed
    142    *  on the queue.
    143    */
     138  #if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
     139    return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
     140  #else
     141    /*
     142     *  No message buffers were available so we may need to return an
     143     *  overflow error or block the sender until the message is placed
     144     *  on the queue.
     145     */
     146    if ( !wait ) {
     147      return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
     148    }
    144149
    145   if ( !wait ) {
    146     return CORE_MESSAGE_QUEUE_STATUS_TOO_MANY;
    147   }
     150    /*
     151     *  Do NOT block on a send if the caller is in an ISR.  It is
     152     *  deadly to block in an ISR.
     153     */
     154    if ( _ISR_Is_in_progress() ) {
     155      return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
     156    }
    148157
    149   /*
    150    *  Do NOT block on a send if the caller is in an ISR.  It is
    151    *  deadly to block in an ISR.
    152    */
     158    /*
     159     *  WARNING!! executing should NOT be used prior to this point.
     160     *  Thus the unusual choice to open a new scope and declare
     161     *  it as a variable.  Doing this emphasizes how dangerous it
     162     *  would be to use this variable prior to here.
     163     */
     164    {
     165      Thread_Control  *executing = _Thread_Executing;
     166      ISR_Level        level;
    153167
    154   if ( _ISR_Is_in_progress() ) {
    155     return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED;
    156   }
     168      _ISR_Disable( level );
     169      _Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
     170      executing->Wait.queue = &the_message_queue->Wait_queue;
     171      executing->Wait.id = id;
     172      executing->Wait.return_argument_second.immutable_object = buffer;
     173      executing->Wait.option = (uint32_t) size;
     174      executing->Wait.count = submit_type;
     175      _ISR_Enable( level );
    157176
    158   /*
    159    *  WARNING!! executing should NOT be used prior to this point.
    160    *  Thus the unusual choice to open a new scope and declare
    161    *  it as a variable.  Doing this emphasizes how dangerous it
    162    *  would be to use this variable prior to here.
    163    */
     177      _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
     178    }
    164179
    165   {
    166     Thread_Control  *executing = _Thread_Executing;
    167 
    168     _ISR_Disable( level );
    169     _Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
    170     executing->Wait.queue = &the_message_queue->Wait_queue;
    171     executing->Wait.id = id;
    172     executing->Wait.return_argument_second.immutable_object = buffer;
    173     executing->Wait.option = (uint32_t) size;
    174     executing->Wait.count = submit_type;
    175     _ISR_Enable( level );
    176 
    177     _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
    178   }
    179 
    180   return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT;
     180    return CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT;
     181  #endif
    181182}
Note: See TracChangeset for help on using the changeset viewer.