Changeset 507d382 in rtems


Ignore:
Timestamp:
Sep 11, 2009, 8:00:30 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 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.
Location:
cpukit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rb094233 r507d382  
     12009-09-11      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * score/include/rtems/score/coremsg.h,
     4        score/inline/rtems/score/coremsg.inl, score/src/coremsg.c,
     5        score/src/coremsginsert.c, score/src/coremsgseize.c,
     6        score/src/coremsgsubmit.c, score/src/objectnametoidstring.c: Disable
     7        the Core Message Queue features of notification, priority messages,
     8        and blocking sends when no API requires them.
     9
    1102009-09-11      Joel Sherrill <joel.sherrill@OARcorp.com>
    211
  • cpukit/score/include/rtems/score/coremsg.h

    rb094233 r507d382  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2007.
     9 *  COPYRIGHT (c) 1989-2009.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    3333#include <rtems/score/priority.h>
    3434#include <rtems/score/watchdog.h>
     35
     36#if defined(RTEMS_POSIX_API)
     37  #define RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY
     38#endif
     39
     40#if defined(RTEMS_POSIX_API)
     41  #define RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION
     42#endif
     43
     44#if defined(RTEMS_POSIX_API)
     45  #define RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND
     46#endif
    3547
    3648#ifdef __cplusplus
     
    7486  /** This element allows this structure to be placed on chains. */
    7587  Chain_Node                 Node;
    76   /** This field is the priority of this message. */
    77   int                        priority;
     88  #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     89    /** This field is the priority of this message. */
     90    int                        priority;
     91  #endif
    7892  /** This field points to the contents of the message. */
    7993  CORE_message_queue_Buffer  Contents;
     
    87101 */
    88102typedef enum {
    89   /** This value indicates that pending messages are in FIFO order. */
     103  /** This value indicates that blocking tasks are in FIFO order. */
    90104  CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
    91   /** This value indicates that pending messages are in priority order. */
     105  /** This value indicates that blocking tasks are in priority order. */
    92106  CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY
    93107}   CORE_message_queue_Disciplines;
     
    168182}   CORE_message_queue_Attributes;
    169183
    170 /**
    171  *  @brief Message Queue Notification Callback Prototype
    172  *
    173  *  The following defines the type for a Notification handler.  A notification
    174  *  handler is invoked when the message queue makes a 0->1 transition on
    175  *  pending messages.
    176  */
    177 typedef void (*CORE_message_queue_Notify_Handler)( void * );
     184#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
     185  /**
     186   *  @brief Message Queue Notification Callback Prototype
     187   *
     188   *  The following defines the type for a Notification handler.  A
     189   *  notification handler is invoked when the message queue makes a
     190   *  0->1 transition on pending messages.
     191   */
     192  typedef void (*CORE_message_queue_Notify_Handler)( void * );
     193#endif
    178194
    179195/**
     
    212228   */
    213229  CORE_message_queue_Buffer         *message_buffers;
    214   /** This is the routine invoked when the message queue transitions
    215    *  from zero (0) messages pending to one (1) message pending.
    216    */
    217   CORE_message_queue_Notify_Handler  notify_handler;
    218   /** This field is the argument passed to the @ref notify_argument. */
    219   void                              *notify_argument;
     230  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
     231    /** This is the routine invoked when the message queue transitions
     232     *  from zero (0) messages pending to one (1) message pending.
     233     */
     234    CORE_message_queue_Notify_Handler  notify_handler;
     235    /** This field is the argument passed to the @ref notify_argument. */
     236    void                              *notify_argument;
     237  #endif
    220238  /** This chain is the set of inactive messages.  A message is inactive
    221239   *  when it does not contain a pending message.
  • cpukit/score/inline/rtems/score/coremsg.inl

    rb094233 r507d382  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2004.
     9 *  COPYRIGHT (c) 1989-2009.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    3434 *  This routine sends a message to the end of the specified message queue.
    3535 */
    36  
    3736RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Send(
    3837  CORE_message_queue_Control                *the_message_queue,
     
    6463 *  This routine sends a message to the front of the specified message queue.
    6564 */
    66  
    6765RTEMS_INLINE_ROUTINE CORE_message_queue_Status _CORE_message_queue_Urgent(
    6866  CORE_message_queue_Control                *the_message_queue,
     
    9593 *  to the destination message buffer.
    9694 */
    97 
    9895RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer (
    9996  const void *source,
     
    109106 *  message buffer chain.
    110107 */
    111 
    112108RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer_control *
    113109_CORE_message_queue_Allocate_message_buffer (
     
    123119 *  message buffer chain.
    124120 */
    125 
    126121RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
    127122    CORE_message_queue_Control        *the_message_queue,
     
    136131 *  and returns a pointer to it.
    137132 */
    138 
    139133RTEMS_INLINE_ROUTINE
    140134  CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message (
     
    150144 *  enabled in the attribute_set and false otherwise.
    151145 */
    152  
    153146RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_priority(
    154147  CORE_message_queue_Attributes *the_attribute
    155148)
    156149{
    157   return (the_attribute->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY);
     150  return
     151    (the_attribute->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY);
    158152}
    159153
     
    162156 *  messages on the_message_queue.
    163157 */
    164 
    165158RTEMS_INLINE_ROUTINE void _CORE_message_queue_Append_unprotected (
    166159  CORE_message_queue_Control        *the_message_queue,
     
    178171 *  messages on the_message_queue.
    179172 */
    180 
    181173RTEMS_INLINE_ROUTINE void _CORE_message_queue_Prepend_unprotected (
    182174  CORE_message_queue_Control        *the_message_queue,
     
    193185 *  This function returns true if the_message_queue is true and false otherwise.
    194186 */
    195 
    196187RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_null (
    197188  CORE_message_queue_Control *the_message_queue
     
    201192}
    202193
    203 /**
    204  *  This function returns true if notification is enabled on this message
    205  *  queue and false otherwise.
    206  */
    207  
    208 RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_notify_enabled (
    209   CORE_message_queue_Control *the_message_queue
    210 )
    211 {
    212   return (the_message_queue->notify_handler != NULL);
    213 }
    214  
    215 /**
    216  *  This routine initializes the notification information for the_message_queue.
    217  */
    218  
    219 RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify (
    220   CORE_message_queue_Control        *the_message_queue,
    221   CORE_message_queue_Notify_Handler  the_handler,
    222   void                              *the_argument
    223 )
    224 {
    225   the_message_queue->notify_handler  = the_handler;
    226   the_message_queue->notify_argument = the_argument;
    227 }
     194#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
     195  /**
     196   *  This function returns true if notification is enabled on this message
     197   *  queue and false otherwise.
     198   */
     199  RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_notify_enabled (
     200    CORE_message_queue_Control *the_message_queue
     201  )
     202  {
     203    return (the_message_queue->notify_handler != NULL);
     204  }
     205 
     206  /**
     207   *  This routine initializes the notification information for
     208   *  @a the_message_queue.
     209   */
     210 
     211  RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify (
     212    CORE_message_queue_Control        *the_message_queue,
     213    CORE_message_queue_Notify_Handler  the_handler,
     214    void                              *the_argument
     215  )
     216  {
     217    the_message_queue->notify_handler  = the_handler;
     218    the_message_queue->notify_argument = the_argument;
     219  }
     220#endif
    228221
    229222/**@}*/
  • cpukit/score/src/coremsg.c

    rb094233 r507d382  
    6363  the_message_queue->number_of_pending_messages = 0;
    6464  the_message_queue->maximum_message_size       = maximum_message_size;
    65   _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
     65  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
     66    _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
     67  #endif
    6668 
    6769  /*
  • cpukit/score/src/coremsginsert.c

    rb094233 r507d382  
    5757{
    5858  ISR_Level  level;
    59   bool       notify = false;
     59  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
     60    bool    notify = false;
     61    #define SET_NOTIFY() \
     62      if ( the_message_queue->number_of_pending_messages == 0 )
     63        notify = true;
     64  #else
     65    #define SET_NOTIFY()
     66  #endif
    6067
    61   the_message->priority = submit_type;
     68  #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     69    the_message->priority = submit_type;
     70  #endif
    6271
    63   switch ( submit_type ) {
    64     case CORE_MESSAGE_QUEUE_SEND_REQUEST:
     72  #if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     73    _ISR_Disable( level );
     74      SET_NOTIFY();
     75      the_message_queue->number_of_pending_messages++;
     76      if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST )
     77        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
     78      else
     79        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
     80    _ISR_Enable( level );
     81  #else
     82    if ( submit_type == CORE_MESSAGE_QUEUE_SEND_REQUEST ) {
    6583      _ISR_Disable( level );
    66         if ( the_message_queue->number_of_pending_messages++ == 0 )
    67           notify = true;
     84        SET_NOTIFY();
     85        the_message_queue->number_of_pending_messages++;
    6886        _CORE_message_queue_Append_unprotected(the_message_queue, the_message);
    6987      _ISR_Enable( level );
    70       break;
    71     case CORE_MESSAGE_QUEUE_URGENT_REQUEST:
     88    } else if ( submit_type == CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
    7289      _ISR_Disable( level );
    73         if ( the_message_queue->number_of_pending_messages++ == 0 )
    74           notify = true;
     90        SET_NOTIFY();
     91        the_message_queue->number_of_pending_messages++;
    7592        _CORE_message_queue_Prepend_unprotected(the_message_queue, the_message);
    7693      _ISR_Enable( level );
    77       break;
    78     default:
    79       {
    80         CORE_message_queue_Buffer_control *this_message;
    81         Chain_Node                        *the_node;
    82         Chain_Control                     *the_header;
     94    } else {
     95      CORE_message_queue_Buffer_control *this_message;
     96      Chain_Node                        *the_node;
     97      Chain_Control                     *the_header;
    8398
    84         the_header = &the_message_queue->Pending_messages;
    85         the_node = the_header->first;
    86         while ( !_Chain_Is_tail( the_header, the_node ) ) {
     99      the_header = &the_message_queue->Pending_messages;
     100      the_node = the_header->first;
     101      while ( !_Chain_Is_tail( the_header, the_node ) ) {
    87102
    88           this_message = (CORE_message_queue_Buffer_control *) the_node;
     103        this_message = (CORE_message_queue_Buffer_control *) the_node;
    89104
    90           if ( this_message->priority <= the_message->priority ) {
    91             the_node = the_node->next;
    92             continue;
    93           }
     105        if ( this_message->priority <= the_message->priority ) {
     106          the_node = the_node->next;
     107          continue;
     108        }
     109        break;
     110      }
     111      _ISR_Disable( level );
     112        SET_NOTIFY();
     113        the_message_queue->number_of_pending_messages++;
     114        _Chain_Insert_unprotected( the_node->previous, &the_message->Node );
     115      _ISR_Enable( level );
     116    }
     117  #endif
    94118
    95           break;
    96         }
    97         _ISR_Disable( level );
    98           if ( the_message_queue->number_of_pending_messages++ == 0 )
    99             notify = true;
    100           _Chain_Insert_unprotected( the_node->previous, &the_message->Node );
    101         _ISR_Enable( level );
    102       }
    103       break;
    104   }
    105 
    106   /*
    107    *  According to POSIX, does this happen before or after the message
    108    *  is actually enqueued.  It is logical to think afterwards, because
    109    *  the message is actually in the queue at this point.
    110    */
    111 
    112   if ( notify && the_message_queue->notify_handler )
    113     (*the_message_queue->notify_handler)( the_message_queue->notify_argument );
     119  #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
     120    /*
     121     *  According to POSIX, does this happen before or after the message
     122     *  is actually enqueued.  It is logical to think afterwards, because
     123     *  the message is actually in the queue at this point.
     124     */
     125    if ( notify && the_message_queue->notify_handler )
     126      (*the_message_queue->notify_handler)(the_message_queue->notify_argument);
     127  #endif
    114128}
  • cpukit/score/src/coremsgseize.c

    rb094233 r507d382  
    6969  CORE_message_queue_Buffer_control *the_message;
    7070  Thread_Control                    *executing;
    71   Thread_Control                    *the_thread;
    7271
    7372  executing = _Thread_Executing;
     
    8079
    8180    *size_p = the_message->Contents.size;
    82     _Thread_Executing->Wait.count = the_message->priority;
     81    #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     82      _Thread_Executing->Wait.count = the_message->priority;
     83    #endif
    8384    _CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size_p);
    8485
    85     /*
    86      *  There could be a thread waiting to send a message.  If there
    87      *  is not, then we can go ahead and free the buffer.
    88      *
    89      *  NOTE: If we note that the queue was not full before this receive,
    90      *  then we can avoid this dequeue.
    91      */
    92 
    93     the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
    94     if ( !the_thread ) {
     86    #if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
     87      /*
     88       *  There is not an API with blocking sends enabled.  So return immediately.
     89       */
    9590      _CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
    9691      return;
     92    #else
     93    {
     94      Thread_Control   *the_thread;
     95
     96      /*
     97       *  There could be a thread waiting to send a message.  If there
     98       *  is not, then we can go ahead and free the buffer.
     99       *
     100       *  NOTE: If we note that the queue was not full before this receive,
     101       *  then we can avoid this dequeue.
     102       */
     103      the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
     104      if ( !the_thread ) {
     105        _CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
     106        return;
     107      }
     108
     109      /*
     110       *  There was a thread waiting to send a message.  This code
     111       *  puts the messages in the message queue on behalf of the
     112       *  waiting task.
     113       */
     114      #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     115        the_message->priority  = the_thread->Wait.count;
     116      #endif
     117      the_message->Contents.size = (size_t) the_thread->Wait.option;
     118      _CORE_message_queue_Copy_buffer(
     119        the_thread->Wait.return_argument_second.immutable_object,
     120        the_message->Contents.buffer,
     121        the_message->Contents.size
     122      );
     123
     124      _CORE_message_queue_Insert_message(
     125         the_message_queue,
     126         the_message,
     127         #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     128           the_message->priority,
     129         #else
     130           0
     131         #endif
     132      );
     133      return;
    97134    }
    98 
    99     /*
    100      *  There was a thread waiting to send a message.  This code
    101      *  puts the messages in the message queue on behalf of the
    102      *  waiting task.
    103      */
    104 
    105     the_message->priority  = the_thread->Wait.count;
    106     the_message->Contents.size = (size_t) the_thread->Wait.option;
    107     _CORE_message_queue_Copy_buffer(
    108       the_thread->Wait.return_argument_second.immutable_object,
    109       the_message->Contents.buffer,
    110       the_message->Contents.size
    111     );
    112 
    113     _CORE_message_queue_Insert_message(
    114        the_message_queue,
    115        the_message,
    116        the_message->priority
    117     );
    118     return;
     135    #endif
    119136  }
    120137
  • 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}
  • cpukit/score/src/objectnametoidstring.c

    rb094233 r507d382  
    1717#endif
    1818
    19 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    2019#include <string.h>
    2120
     
    3231#include <rtems/score/isr.h>
    3332
     33#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    3434/*PAGE
    3535 *
Note: See TracChangeset for help on using the changeset viewer.