Changeset 939ba81 in rtems


Ignore:
Timestamp:
Sep 13, 2009, 4:05:14 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
50d1e154
Parents:
302e436
Message:

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

  • score/inline/rtems/score/coremsg.inl, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c: Add wrappers for accessing message priority. Since these are empty when priority-based message queues are disabled, this eliminates some of the conditionals.
Location:
cpukit
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r302e436 r939ba81  
     12009-09-13      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * score/inline/rtems/score/coremsg.inl, score/src/coremsg.c,
     4        score/src/coremsgbroadcast.c, score/src/coremsginsert.c,
     5        score/src/coremsgseize.c, score/src/coremsgsubmit.c: Add wrappers for
     6        accessing message priority. Since these are empty when priority-based
     7        message queues are disabled, this eliminates some of the
     8        conditionals.
     9
    1102009-09-12      Joel Sherrill <joel.sherrill@oarcorp.com>
    211
  • cpukit/score/inline/rtems/score/coremsg.inl

    r302e436 r939ba81  
    120120 */
    121121RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer (
    122     CORE_message_queue_Control        *the_message_queue,
    123     CORE_message_queue_Buffer_control *the_message
     122  CORE_message_queue_Control        *the_message_queue,
     123  CORE_message_queue_Buffer_control *the_message
    124124)
    125125{
    126126  _Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node );
     127}
     128
     129/**
     130 *  This function returns the priority of @a the_message.
     131 *
     132 *  NOTE: It encapsulates the optional behavior that message priority is
     133 *        disabled if no API requires it.
     134 */
     135RTEMS_INLINE_ROUTINE int _CORE_message_queue_Get_message_priority (
     136  CORE_message_queue_Buffer_control *the_message
     137)
     138{
     139  #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     140    return the_message->priority;
     141  #else
     142    return 0;
     143  #endif
     144}
     145
     146/**
     147 *  This function sets the priority of @a the_message.
     148 *
     149 *  NOTE: It encapsulates the optional behavior that message priority is
     150 *        disabled if no API requires it.
     151 */
     152RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_message_priority (
     153  CORE_message_queue_Buffer_control *the_message,
     154  int                                priority 
     155)
     156{
     157  the_message->priority = priority;
    127158}
    128159
     
    203234    return (the_message_queue->notify_handler != NULL);
    204235  }
     236#endif
    205237 
    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
     238/**
     239 *  This routine initializes the notification information for
     240 *  @a the_message_queue.
     241 */
     242RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify (
     243  CORE_message_queue_Control        *the_message_queue,
     244  CORE_message_queue_Notify_Handler  the_handler,
     245  void                              *the_argument
     246)
     247{
     248#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
     249  the_message_queue->notify_handler  = the_handler;
     250  the_message_queue->notify_argument = the_argument;
     251#endif
     252}
    221253
    222254/**@}*/
  • cpukit/score/src/coremsg.c

    r302e436 r939ba81  
    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 *
     
    3131#include <rtems/score/wkspace.h>
    3232
    33 /*PAGE
    34  *
     33/*
    3534 *  _CORE_message_queue_Initialize
    3635 *
     
    6362  the_message_queue->number_of_pending_messages = 0;
    6463  the_message_queue->maximum_message_size       = maximum_message_size;
    65   #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
    66     _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
    67   #endif
     64  _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
    6865 
    6966  /*
     
    7168   *  check for overflow on adding overhead to each message.
    7269   */
    73  
    7470  allocated_message_size = maximum_message_size;
    7571  if (allocated_message_size & (sizeof(uint32_t) - 1)) {
    76       allocated_message_size += sizeof(uint32_t);
    77       allocated_message_size &= ~(sizeof(uint32_t) - 1);
     72    allocated_message_size += sizeof(uint32_t);
     73    allocated_message_size &= ~(sizeof(uint32_t) - 1);
    7874  }
    7975   
  • cpukit/score/src/coremsgbroadcast.c

    r302e436 r939ba81  
    5656  const void                                *buffer,
    5757  size_t                                     size,
    58 #if defined(RTEMS_MULTIPROCESSING)
    59   Objects_Id                                 id,
    60   CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support,
    61 #else
    62   Objects_Id                                 id __attribute__((unused)),
    63   CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support __attribute__((unused)),
    64 #endif
     58  #if defined(RTEMS_MULTIPROCESSING)
     59    Objects_Id                                 id,
     60    CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support,
     61  #else
     62    Objects_Id                                 id __attribute__((unused)),
     63    CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support __attribute__((unused)),
     64  #endif
    6565  uint32_t                                  *count
    6666)
     
    9292   *  receive a message.
    9393   */
    94 
    9594  number_broadcasted = 0;
    96   while ((the_thread = _Thread_queue_Dequeue(&the_message_queue->Wait_queue))) {
     95  while ((the_thread =
     96          _Thread_queue_Dequeue(&the_message_queue->Wait_queue) != NULL)) {
    9797    waitp = &the_thread->Wait;
    9898    number_broadcasted += 1;
     
    106106    *(size_t *) the_thread->Wait.return_argument = size;
    107107
    108 #if defined(RTEMS_MULTIPROCESSING)
    109     if ( !_Objects_Is_local_id( the_thread->Object.id ) )
    110       (*api_message_queue_mp_support) ( the_thread, id );
    111 #endif
     108    #if defined(RTEMS_MULTIPROCESSING)
     109      if ( !_Objects_Is_local_id( the_thread->Object.id ) )
     110        (*api_message_queue_mp_support) ( the_thread, id );
     111    #endif
    112112
    113113  }
  • cpukit/score/src/coremsginsert.c

    r302e436 r939ba81  
    6666  #endif
    6767
    68   #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
    69     the_message->priority = submit_type;
    70   #endif
     68  _CORE_message_queue_Set_message_priority( the_message, submit_type );
    7169
    7270  #if !defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
     
    9694      Chain_Node                        *the_node;
    9795      Chain_Control                     *the_header;
     96      int                                the_priority;
    9897
     98      the_priority = _CORE_message_queue_Get_message_priority(the_message);
    9999      the_header = &the_message_queue->Pending_messages;
    100100      the_node = the_header->first;
    101101      while ( !_Chain_Is_tail( the_header, the_node ) ) {
     102        int this_priority;
    102103
    103104        this_message = (CORE_message_queue_Buffer_control *) the_node;
    104105
    105         if ( this_message->priority <= the_message->priority ) {
     106        this_priority = _CORE_message_queue_Get_message_priority(this_message);
     107
     108        if ( this_priority <= the_priority ) {
    106109          the_node = the_node->next;
    107110          continue;
  • cpukit/score/src/coremsgseize.c

    r302e436 r939ba81  
    7979
    8080    *size_p = the_message->Contents.size;
    81     #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
    82       _Thread_Executing->Wait.count = the_message->priority;
    83     #endif
    84     _CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size_p);
     81    _Thread_Executing->Wait.count =
     82      _CORE_message_queue_Get_message_priority( the_message );
     83    _CORE_message_queue_Copy_buffer(
     84      the_message->Contents.buffer,
     85      buffer,
     86      *size_p
     87    );
    8588
    8689    #if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
    8790      /*
    88        *  There is not an API with blocking sends enabled.  So return immediately.
     91       *  There is not an API with blocking sends enabled.
     92       *  So return immediately.
    8993       */
    90       _CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
     94      _CORE_message_queue_Free_message_buffer(the_message_queue, the_message);
    9195      return;
    9296    #else
     
    103107      the_thread = _Thread_queue_Dequeue( &the_message_queue->Wait_queue );
    104108      if ( !the_thread ) {
    105         _CORE_message_queue_Free_message_buffer( the_message_queue, the_message );
     109        _CORE_message_queue_Free_message_buffer(
     110          the_message_queue,
     111          the_message
     112        );
    106113        return;
    107114      }
     
    112119       *  waiting task.
    113120       */
    114       #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
    115         the_message->priority  = the_thread->Wait.count;
    116       #endif
     121      _CORE_message_queue_Set_message_priority(
     122        the_message,
     123        the_thread->Wait.count
     124      );
    117125      the_message->Contents.size = (size_t) the_thread->Wait.option;
    118126      _CORE_message_queue_Copy_buffer(
     
    125133         the_message_queue,
    126134         the_message,
    127          #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
    128            the_message->priority
    129          #else
    130            0
    131          #endif
     135         _CORE_message_queue_Get_message_priority( the_message )
    132136      );
    133137      return;
  • cpukit/score/src/coremsgsubmit.c

    r302e436 r939ba81  
    6060  size_t                                     size,
    6161  Objects_Id                                 id,
    62 #if defined(RTEMS_MULTIPROCESSING)
    63   CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support,
    64 #else
    65   CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support __attribute__((unused)),
    66 #endif
     62  #if defined(RTEMS_MULTIPROCESSING)
     63    CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support,
     64  #else
     65    CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support  __attribute__((unused)),
     66  #else
     67  #endif
    6768  CORE_message_queue_Submit_types            submit_type,
    6869  bool                                       wait,
     
    9192      the_thread->Wait.count = submit_type;
    9293
    93 #if defined(RTEMS_MULTIPROCESSING)
    94       if ( !_Objects_Is_local_id( the_thread->Object.id ) )
    95         (*api_message_queue_mp_support) ( the_thread, id );
    96 #endif
     94      #if defined(RTEMS_MULTIPROCESSING)
     95        if ( !_Objects_Is_local_id( the_thread->Object.id ) )
     96          (*api_message_queue_mp_support) ( the_thread, id );
     97      #endif
    9798      return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    9899    }
     
    124125    );
    125126    the_message->Contents.size = size;
    126     #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
    127       the_message->priority  = submit_type;
    128     #endif
     127    _CORE_message_queue_Set_message_priority( the_message, submit_type );
    129128
    130129    _CORE_message_queue_Insert_message(
Note: See TracChangeset for help on using the changeset viewer.