Changeset 9693fdac in rtems


Ignore:
Timestamp:
Nov 2, 1999, 3:57:58 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
8f0529f
Parents:
af10d3ef
Message:

Added support for message priority as required by POSIX.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/include/rtems/score/coremsg.h

    raf10d3ef r9693fdac  
    5757typedef struct {
    5858  Chain_Node                 Node;
     59  int                        priority;
    5960  CORE_message_queue_Buffer  Contents;
    6061}   CORE_message_queue_Buffer_control;
     
    7374 *  may be submitted to a message queue.  The message may be posted
    7475 *  in a send or urgent fashion.
    75  */
    76  
    77 typedef enum {
    78   CORE_MESSAGE_QUEUE_SEND_REQUEST   = 0,
    79   CORE_MESSAGE_QUEUE_URGENT_REQUEST = 1
    80 }  CORE_message_queue_Submit_types;
     76 *
     77 *  NOTE:  All other values are message priorities.  Numerically smaller
     78 *         priorities indicate higher priority messages.
     79 *
     80 *  XXX these constants should be changed to be compiler dependent.
     81 */
     82 
     83#define  CORE_MESSAGE_QUEUE_SEND_REQUEST   0x7fffffff
     84#define  CORE_MESSAGE_QUEUE_URGENT_REQUEST -(0x7fffffff)
     85
     86typedef int CORE_message_queue_Submit_types;
    8187
    8288/*
  • c/src/exec/score/src/coremsg.c

    raf10d3ef r9693fdac  
    423423  _CORE_message_queue_Copy_buffer( buffer, the_message->Contents.buffer, size );
    424424  the_message->Contents.size = size;
    425  
     425  the_message->priority  = submit_type;
     426
    426427  the_message_queue->number_of_pending_messages += 1;
    427428
     
    433434      _CORE_message_queue_Prepend( the_message_queue, the_message );
    434435      break;
    435   }
    436 
     436    default:
     437      /* XXX interrupt critical section needs to be addressed */
     438      {
     439        CORE_message_queue_Buffer_control *this_message;
     440        Chain_Node                        *the_node;
     441
     442        the_message->priority = submit_type;
     443        for ( the_node = the_message_queue->Pending_messages.first ;
     444           !_Chain_Is_tail( &the_message_queue->Pending_messages, the_node ) ;
     445           the_node = the_node->next ) {
     446
     447          this_message = (CORE_message_queue_Buffer_control *) the_node;
     448
     449          if ( this_message->priority >= the_message->priority )
     450            continue;
     451
     452          _Chain_Insert( the_node, &the_message->Node );
     453          break;
     454        }
     455      }
     456      break;
     457  }
     458
     459  /*
     460   *  According to POSIX, does this happen before or after the message
     461   *  is actually enqueued.  It is logical to think afterwards, because
     462   *  the message is actually in the queue at this point.
     463   */
     464
     465  if ( the_message_queue->number_of_pending_messages == 1 &&
     466       the_message_queue->notify_handler )
     467    (*the_message_queue->notify_handler)( the_message_queue->notify_argument );
     468 
    437469  return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    438470}
  • cpukit/score/include/rtems/score/coremsg.h

    raf10d3ef r9693fdac  
    5757typedef struct {
    5858  Chain_Node                 Node;
     59  int                        priority;
    5960  CORE_message_queue_Buffer  Contents;
    6061}   CORE_message_queue_Buffer_control;
     
    7374 *  may be submitted to a message queue.  The message may be posted
    7475 *  in a send or urgent fashion.
    75  */
    76  
    77 typedef enum {
    78   CORE_MESSAGE_QUEUE_SEND_REQUEST   = 0,
    79   CORE_MESSAGE_QUEUE_URGENT_REQUEST = 1
    80 }  CORE_message_queue_Submit_types;
     76 *
     77 *  NOTE:  All other values are message priorities.  Numerically smaller
     78 *         priorities indicate higher priority messages.
     79 *
     80 *  XXX these constants should be changed to be compiler dependent.
     81 */
     82 
     83#define  CORE_MESSAGE_QUEUE_SEND_REQUEST   0x7fffffff
     84#define  CORE_MESSAGE_QUEUE_URGENT_REQUEST -(0x7fffffff)
     85
     86typedef int CORE_message_queue_Submit_types;
    8187
    8288/*
  • cpukit/score/src/coremsg.c

    raf10d3ef r9693fdac  
    423423  _CORE_message_queue_Copy_buffer( buffer, the_message->Contents.buffer, size );
    424424  the_message->Contents.size = size;
    425  
     425  the_message->priority  = submit_type;
     426
    426427  the_message_queue->number_of_pending_messages += 1;
    427428
     
    433434      _CORE_message_queue_Prepend( the_message_queue, the_message );
    434435      break;
    435   }
    436 
     436    default:
     437      /* XXX interrupt critical section needs to be addressed */
     438      {
     439        CORE_message_queue_Buffer_control *this_message;
     440        Chain_Node                        *the_node;
     441
     442        the_message->priority = submit_type;
     443        for ( the_node = the_message_queue->Pending_messages.first ;
     444           !_Chain_Is_tail( &the_message_queue->Pending_messages, the_node ) ;
     445           the_node = the_node->next ) {
     446
     447          this_message = (CORE_message_queue_Buffer_control *) the_node;
     448
     449          if ( this_message->priority >= the_message->priority )
     450            continue;
     451
     452          _Chain_Insert( the_node, &the_message->Node );
     453          break;
     454        }
     455      }
     456      break;
     457  }
     458
     459  /*
     460   *  According to POSIX, does this happen before or after the message
     461   *  is actually enqueued.  It is logical to think afterwards, because
     462   *  the message is actually in the queue at this point.
     463   */
     464
     465  if ( the_message_queue->number_of_pending_messages == 1 &&
     466       the_message_queue->notify_handler )
     467    (*the_message_queue->notify_handler)( the_message_queue->notify_argument );
     468 
    437469  return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    438470}
Note: See TracChangeset for help on using the changeset viewer.