Changeset c654b525 in rtems


Ignore:
Timestamp:
Apr 30, 2015, 11:18:45 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
cc18d7b
Parents:
f5d6c8b
git-author:
Sebastian Huber <sebastian.huber@…> (04/30/15 11:18:45)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/19/15 10:00:46)
Message:

score: Delete _CORE_message_queue_Flush_support()

Check the number of pending messages in _CORE_message_queue_Flush() to
avoid race conditions.

Location:
cpukit/score
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    rf5d6c8b rc654b525  
    159159libscore_a_SOURCES += src/coremsg.c src/coremsgbroadcast.c \
    160160    src/coremsgclose.c src/coremsgflush.c src/coremsgflushwait.c \
    161     src/coremsginsert.c src/coremsgflushsupp.c src/coremsgseize.c \
     161    src/coremsginsert.c src/coremsgseize.c \
    162162    src/coremsgsubmit.c
    163163
  • cpukit/score/include/rtems/score/coremsgimpl.h

    rf5d6c8b rc654b525  
    180180);
    181181
    182 /**
    183  *  @brief Flush all outstanding messages.
    184  *
    185  *  This routine flushes all outstanding messages and returns
    186  *  them to the inactive message chain.
    187  *
    188  *  @param[in] the_message_queue points to the message queue to flush
    189  *
    190  *  @retval This method returns the number of pending messages flushed.
    191  *
    192  *  - INTERRUPT LATENCY:
    193  *    + single case
    194  */
    195 uint32_t   _CORE_message_queue_Flush_support(
    196   CORE_message_queue_Control *the_message_queue
    197 );
    198 
    199182#if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
    200183/**
  • cpukit/score/src/coremsgclose.c

    rf5d6c8b rc654b525  
    5050   */
    5151
    52   if ( the_message_queue->number_of_pending_messages != 0 )
    53     (void) _CORE_message_queue_Flush_support( the_message_queue );
     52  (void) _CORE_message_queue_Flush( the_message_queue );
    5453
    5554  (void) _Workspace_Free( the_message_queue->message_buffers );
  • cpukit/score/src/coremsgflush.c

    rf5d6c8b rc654b525  
    11/**
    2  *  @file
     2 * @file
    33 *
    4  *  @brief Flush Pending Messages
    5  *  @ingroup ScoreMessageQueue
     4 * @brief Flush Messages Routine
     5 *
     6 * @ingroup ScoreMessageQueue
    67 */
    78
     
    1920#endif
    2021
    21 #include <rtems/system.h>
    22 #include <rtems/score/chain.h>
     22#include <rtems/score/coremsgimpl.h>
    2323#include <rtems/score/isr.h>
    24 #include <rtems/score/coremsgimpl.h>
    25 #include <rtems/score/thread.h>
    26 #include <rtems/score/wkspace.h>
    2724
    2825uint32_t   _CORE_message_queue_Flush(
     
    3027)
    3128{
    32   if ( the_message_queue->number_of_pending_messages != 0 )
    33     return _CORE_message_queue_Flush_support( the_message_queue );
    34   else
    35     return 0;
     29  ISR_Level   level;
     30  Chain_Node *inactive_head;
     31  Chain_Node *inactive_first;
     32  Chain_Node *message_queue_first;
     33  Chain_Node *message_queue_last;
     34  uint32_t    count;
     35
     36  /*
     37   *  Currently, RTEMS supports no API that has both flush and blocking
     38   *  sends.  Thus, this routine assumes that there are no senders
     39   *  blocked waiting to send messages.  In the event, that an API is
     40   *  added that can flush a message queue when threads are blocked
     41   *  waiting to send, there are two basic behaviors envisioned:
     42   *
     43   *  (1) The thread queue of pending senders is a logical extension
     44   *  of the pending message queue.  In this case, it should be
     45   *  flushed using the _Thread_queue_Flush() service with a status
     46   *  such as CORE_MESSAGE_QUEUE_SENDER_FLUSHED (which currently does
     47   *  not exist).  This can be implemented without changing the "big-O"
     48   *  of the message flushing part of the routine.
     49   *
     50   *  (2) Only the actual messages queued should be purged.  In this case,
     51   *  the blocked sender threads must be allowed to send their messages.
     52   *  In this case, the implementation will be forced to individually
     53   *  dequeue the senders and queue their messages.  This will force
     54   *  this routine to have "big O(n)" where n is the number of blocked
     55   *  senders.  If there are more messages pending than senders blocked,
     56   *  then the existing flush code can be used to dispose of the remaining
     57   *  pending messages.
     58   *
     59   *  For now, though, we are very happy to have a small routine with
     60   *  fixed execution time that only deals with pending messages.
     61   */
     62
     63  _ISR_Disable( level );
     64
     65  count = the_message_queue->number_of_pending_messages;
     66  if ( count != 0 ) {
     67    the_message_queue->number_of_pending_messages = 0;
     68
     69    inactive_head = _Chain_Head( &the_message_queue->Inactive_messages );
     70    inactive_first = inactive_head->next;
     71    message_queue_first = _Chain_First( &the_message_queue->Pending_messages );
     72    message_queue_last = _Chain_Last( &the_message_queue->Pending_messages );
     73
     74    inactive_head->next = message_queue_first;
     75    message_queue_last->next = inactive_first;
     76    inactive_first->previous = message_queue_last;
     77    message_queue_first->previous = inactive_head;
     78
     79    _Chain_Initialize_empty( &the_message_queue->Pending_messages );
     80  }
     81
     82  _ISR_Enable( level );
     83  return count;
    3684}
Note: See TracChangeset for help on using the changeset viewer.