Changeset 3168deaa in rtems


Ignore:
Timestamp:
Jan 22, 2008, 6:28:53 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
8b7a713
Parents:
b89f64c
Message:

2008-01-22 Joel Sherrill <joel.sherrill@…>

  • rtems/include/rtems/rtems/event.h, rtems/inline/rtems/rtems/eventset.inl, rtems/src/event.c, rtems/src/eventseize.c, rtems/src/eventsurrender.c, rtems/src/eventtimeout.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/interr.h, score/include/rtems/score/thread.h, score/include/rtems/score/threadq.h, score/include/rtems/score/tqdata.h, score/inline/rtems/score/threadq.inl, score/inline/rtems/score/tqdata.inl, score/src/threadq.c, score/src/threadqdequeue.c, score/src/threadqdequeuefifo.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueue.c, score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c, score/src/threadqextract.c, score/src/threadqextractfifo.c, score/src/threadqextractpriority.c, score/src/threadqextractwithproxy.c, score/src/threadqfirst.c, score/src/threadqfirstfifo.c, score/src/threadqfirstpriority.c, score/src/threadqflush.c, score/src/threadqrequeue.c, score/src/threadqtimeout.c: Refactor thread queue enqueue and event blocking synchronization critical sections. This resulted in three copies of essentially the same hard to test critical section code becoming the one shared routine _Thread_blocking_operation_Cancel. In addition, the thread queue and event code now share a common synchronization enumerated type. Along the way, switches were reworked to eliminate dead code generated by gcc and comments and copyrights were updated.
  • score/include/rtems/score/threadsync.h, score/src/threadblockingoperationcancel.c: New files.
Location:
cpukit
Files:
2 added
32 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rb89f64c r3168deaa  
     12008-01-22      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * rtems/include/rtems/rtems/event.h,
     4        rtems/inline/rtems/rtems/eventset.inl, rtems/src/event.c,
     5        rtems/src/eventseize.c, rtems/src/eventsurrender.c,
     6        rtems/src/eventtimeout.c, score/Makefile.am, score/preinstall.am,
     7        score/include/rtems/score/interr.h,
     8        score/include/rtems/score/thread.h,
     9        score/include/rtems/score/threadq.h,
     10        score/include/rtems/score/tqdata.h,
     11        score/inline/rtems/score/threadq.inl,
     12        score/inline/rtems/score/tqdata.inl, score/src/threadq.c,
     13        score/src/threadqdequeue.c, score/src/threadqdequeuefifo.c,
     14        score/src/threadqdequeuepriority.c, score/src/threadqenqueue.c,
     15        score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c,
     16        score/src/threadqextract.c, score/src/threadqextractfifo.c,
     17        score/src/threadqextractpriority.c,
     18        score/src/threadqextractwithproxy.c, score/src/threadqfirst.c,
     19        score/src/threadqfirstfifo.c, score/src/threadqfirstpriority.c,
     20        score/src/threadqflush.c, score/src/threadqrequeue.c,
     21        score/src/threadqtimeout.c: Refactor thread queue enqueue and event
     22        blocking synchronization critical sections. This resulted in three
     23        copies of essentially the same hard to test critical section code
     24        becoming the one shared routine _Thread_blocking_operation_Cancel. In
     25        addition, the thread queue and event code now share a common
     26        synchronization enumerated type. Along the way, switches were
     27        reworked to eliminate dead code generated by gcc and comments and
     28        copyrights were updated.
     29        * score/include/rtems/score/threadsync.h,
     30        score/src/threadblockingoperationcancel.c: New files.
     31
    1322008-01-22      Joel Sherrill <joel.sherrill@OARcorp.com>
    233
  • cpukit/rtems/include/rtems/rtems/event.h

    rb89f64c r3168deaa  
    1414 *
    1515 *
    16  *  COPYRIGHT (c) 1989-2007.
     16 *  COPYRIGHT (c) 1989-2008.
    1717 *  On-Line Applications Research Corporation (OAR).
    1818 *
     
    4040#include <rtems/rtems/options.h>
    4141#include <rtems/score/thread.h>
     42#include <rtems/score/threadsync.h>
    4243#include <rtems/score/watchdog.h>
    4344#include <rtems/rtems/eventset.h>
     
    4950
    5051#define EVENT_CURRENT  0
    51 
    52 /*
    53  *  The following enumerated types indicate what happened while the event
    54  *  manager was in the synchronization window.
    55  */
    56 
    57 typedef enum {
    58   EVENT_SYNC_SYNCHRONIZED,
    59   EVENT_SYNC_NOTHING_HAPPENED,
    60   EVENT_SYNC_TIMEOUT,
    61   EVENT_SYNC_SATISFIED
    62 }  Event_Sync_states;
    6352
    6453/*
     
    167156 */
    168157
    169 RTEMS_EVENT_EXTERN volatile Event_Sync_states _Event_Sync_state;
     158RTEMS_EVENT_EXTERN volatile Thread_blocking_operation_States _Event_Sync_state;
    170159
    171160#if defined(RTEMS_MULTIPROCESSING)
  • cpukit/rtems/inline/rtems/rtems/eventset.inl

    rb89f64c r3168deaa  
    66 *  This include file contains the information pertaining to event sets.
    77 *
    8  *  COPYRIGHT (c) 1989-1999.
     8 *  COPYRIGHT (c) 1989-2008.
    99 *  On-Line Applications Research Corporation (OAR).
    1010 *
  • cpukit/rtems/src/event.c

    rb89f64c r3168deaa  
    22 *  Event Manager
    33 *
    4  *  COPYRIGHT (c) 1989-1999.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
     
    3737void _Event_Manager_initialization( void )
    3838{
    39   _Event_Sync_state = EVENT_SYNC_SYNCHRONIZED;
     39  _Event_Sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
    4040
    4141  /*
  • cpukit/rtems/src/eventseize.c

    rb89f64c r3168deaa  
    22 *  Event Manager
    33 *
    4  *  COPYRIGHT (c) 1989-1999.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
     
    5555)
    5656{
    57   Thread_Control    *executing;
    58   rtems_event_set    seized_events;
    59   rtems_event_set    pending_events;
    60   ISR_Level          level;
    61   RTEMS_API_Control  *api;
    62   Event_Sync_states   sync_state;
     57  Thread_Control                   *executing;
     58  rtems_event_set                   seized_events;
     59  rtems_event_set                   pending_events;
     60  ISR_Level                         level;
     61  RTEMS_API_Control                *api;
     62  Thread_blocking_operation_States  sync_state;
    6363
    6464  executing = _Thread_Executing;
     
    8787  }
    8888
    89   _Event_Sync_state = EVENT_SYNC_NOTHING_HAPPENED;
     89  _Event_Sync_state = THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    9090
    9191  executing->Wait.option            = (uint32_t) option_set;
     
    110110
    111111  sync_state = _Event_Sync_state;
    112   _Event_Sync_state = EVENT_SYNC_SYNCHRONIZED;
     112  _Event_Sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
     113  if ( sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
     114    _ISR_Enable( level );
     115    return;
     116  }
    113117
    114   switch ( sync_state ) {
    115     case EVENT_SYNC_SYNCHRONIZED:
    116       /*
    117        *  This cannot happen.  It indicates that this routine did not
    118        *  enter the synchronization states above.
    119        */
    120       break;
    121 
    122     case EVENT_SYNC_NOTHING_HAPPENED:
    123       _ISR_Enable( level );
    124       break;
    125 
    126     case EVENT_SYNC_TIMEOUT:
    127       executing->Wait.return_code = RTEMS_TIMEOUT;
    128       _ISR_Enable( level );
    129       _Thread_Unblock( executing );
    130       break;
    131 
    132     case EVENT_SYNC_SATISFIED:
    133       if ( _Watchdog_Is_active( &executing->Timer ) ) {
    134         _Watchdog_Deactivate( &executing->Timer );
    135         _ISR_Enable( level );
    136         (void) _Watchdog_Remove( &executing->Timer );
    137       } else
    138         _ISR_Enable( level );
    139       _Thread_Unblock( executing );
    140       break;
    141   }
     118  /*
     119   *  An interrupt completed the thread's blocking request.
     120   *  The blocking thread was satisfied by an ISR or timed out.
     121   *
     122   *  WARNING! Returning with interrupts disabled!
     123   */
     124  _Thread_blocking_operation_Cancel( sync_state, executing, level );
    142125}
  • cpukit/rtems/src/eventsurrender.c

    rb89f64c r3168deaa  
    22 *  Event Manager
    33 *
    4  *  COPYRIGHT (c) 1989-1999.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
     
    6464  seized_events = _Event_sets_Get( pending_events, event_condition );
    6565
    66   if ( !_Event_sets_Is_empty( seized_events ) ) {
    67     if ( _States_Is_waiting_for_event( the_thread->current_state ) ) {
    68       if ( seized_events == event_condition || _Options_Is_any( option_set ) ) {
    69         api->pending_events =
    70            _Event_sets_Clear( pending_events, seized_events );
    71         the_thread->Wait.count = 0;
    72         *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
     66  /*
     67   *  No events were seized in this operation
     68   */
     69  if ( _Event_sets_Is_empty( seized_events ) )
     70    return;
    7371
    74         _ISR_Flash( level );
     72  /*
     73   *  If we are in an ISR and sending to the current thread, then
     74   *  we have a critical section issue to deal with.
     75   */
     76  if ( _ISR_Is_in_progress() &&
     77       _Thread_Is_executing( the_thread ) &&
     78       ((_Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ||
     79        (_Event_Sync_state == THREAD_BLOCKING_OPERATION_TIMEOUT)) ) {
     80    if ( seized_events == event_condition || _Options_Is_any(option_set) ) {
     81      api->pending_events = _Event_sets_Clear( pending_events,seized_events );
     82      the_thread->Wait.count = 0;
     83      *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
     84      _Event_Sync_state = THREAD_BLOCKING_OPERATION_SATISFIED;
     85    }
     86    _ISR_Enable( level );
     87    return;
     88  }
    7589
    76         if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
    77           _ISR_Enable( level );
    78           _Thread_Unblock( the_thread );
    79         }
    80         else {
    81           _Watchdog_Deactivate( &the_thread->Timer );
    82           _ISR_Enable( level );
    83           (void) _Watchdog_Remove( &the_thread->Timer );
    84           _Thread_Unblock( the_thread );
    85         }
    86         return;
     90  /*
     91   *  Otherwise, this is a normal send to another thread
     92   */
     93  if ( _States_Is_waiting_for_event( the_thread->current_state ) ) {
     94    if ( seized_events == event_condition || _Options_Is_any( option_set ) ) {
     95      api->pending_events = _Event_sets_Clear( pending_events, seized_events );
     96      the_thread->Wait.count = 0;
     97      *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
     98
     99      _ISR_Flash( level );
     100
     101      if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
     102        _ISR_Enable( level );
     103        _Thread_Unblock( the_thread );
     104      } else {
     105        _Watchdog_Deactivate( &the_thread->Timer );
     106        _ISR_Enable( level );
     107        (void) _Watchdog_Remove( &the_thread->Timer );
     108        _Thread_Unblock( the_thread );
    87109      }
    88     }
    89 
    90     switch ( _Event_Sync_state ) {
    91       case EVENT_SYNC_SYNCHRONIZED:
    92       case EVENT_SYNC_SATISFIED:
    93         break;
    94 
    95       case EVENT_SYNC_NOTHING_HAPPENED:
    96       case EVENT_SYNC_TIMEOUT:
    97         if ( !_Thread_Is_executing( the_thread ) )
    98           break;
    99 
    100         if ( seized_events == event_condition || _Options_Is_any(option_set) ) {
    101           api->pending_events =
    102                _Event_sets_Clear( pending_events,seized_events );
    103           the_thread->Wait.count = 0;
    104           *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
    105           _Event_Sync_state = EVENT_SYNC_SATISFIED;
    106         }
    107         break;
     110      return;
    108111    }
    109112  }
  • cpukit/rtems/src/eventtimeout.c

    rb89f64c r3168deaa  
    22 *  Event Manager
    33 *
    4  *  COPYRIGHT (c) 1989-2007.
     4 *  COPYRIGHT (c) 1989-2008.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
     
    6565       */
    6666
     67
    6768      _ISR_Disable( level );
    68       if ( the_thread->Wait.count ) {  /* verify thread is waiting */
     69        if ( !the_thread->Wait.count ) {  /* verify thread is waiting */
     70          _Thread_Unnest_dispatch();
     71          _ISR_Enable( level );
     72          return;
     73        }
     74
    6975        the_thread->Wait.count = 0;
    70         if ( _Event_Sync_state != EVENT_SYNC_SYNCHRONIZED &&
    71              _Thread_Is_executing( the_thread ) ) {
    72           if ( _Event_Sync_state != EVENT_SYNC_SATISFIED ) {
    73             _Event_Sync_state = EVENT_SYNC_TIMEOUT;
     76        if ( _Thread_Is_executing( the_thread ) ) {
     77          Thread_blocking_operation_States sync = _Event_Sync_state;
     78          if ( (sync == THREAD_BLOCKING_OPERATION_SYNCHRONIZED) ||
     79               (sync == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) {
     80            _Event_Sync_state = THREAD_BLOCKING_OPERATION_TIMEOUT;
    7481          }
    75           _ISR_Enable( level );
    76         } else {
    77             the_thread->Wait.return_code = RTEMS_TIMEOUT;
    78             _ISR_Enable( level );
    79             _Thread_Unblock( the_thread );
    8082        }
    81       }
    82       else {
    83         _ISR_Enable( level );
    84       }
    8583
     84        the_thread->Wait.return_code = RTEMS_TIMEOUT;
     85      _ISR_Enable( level );
     86      _Thread_Unblock( the_thread );
    8687      _Thread_Unnest_dispatch();
    8788      break;
  • cpukit/score/Makefile.am

    rb89f64c r3168deaa  
    2929    include/rtems/score/stack.h include/rtems/score/states.h \
    3030    include/rtems/score/sysstate.h include/rtems/score/thread.h \
    31     include/rtems/score/threadq.h include/rtems/score/timespec.h \
    32     include/rtems/score/tod.h include/rtems/score/tqdata.h \
    33     include/rtems/score/userext.h include/rtems/score/watchdog.h \
    34     include/rtems/score/wkspace.h include/rtems/score/cpuopts.h
     31    include/rtems/score/threadq.h include/rtems/score/threadsync.h \
     32    include/rtems/score/timespec.h include/rtems/score/tod.h \
     33    include/rtems/score/tqdata.h include/rtems/score/userext.h \
     34    include/rtems/score/watchdog.h include/rtems/score/wkspace.h \
     35    include/rtems/score/cpuopts.h
    3536
    3637if HAS_MP
     
    143144    src/threadstackfree.c src/threadstart.c src/threadstartmultitasking.c \
    144145    src/threadsuspend.c src/threadtickletimeslice.c \
    145     src/threadyieldprocessor.c src/iterateoverthreads.c
     146    src/threadyieldprocessor.c src/iterateoverthreads.c \
     147    src/threadblockingoperationcancel.c
    146148
    147149## THREAD_C_FILES only used by ITRON API
  • cpukit/score/include/rtems/score/interr.h

    rb89f64c r3168deaa  
    6464  INTERNAL_ERROR_BAD_STACK_HOOK,
    6565  INTERNAL_ERROR_BAD_ATTRIBUTES,
    66   INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY
     66  INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY,
     67  INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
    6768} Internal_errors_Core_list;
    6869
  • cpukit/score/include/rtems/score/thread.h

    rb89f64c r3168deaa  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2007.
     9 *  COPYRIGHT (c) 1989-2008.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    786786);
    787787
     788/**
     789 *  @brief Cancel a blocking operation due to ISR
     790 *
     791 *  This method is used to cancel a blocking operation that was
     792 *  satisfied from an ISR while the thread executing was in the
     793 *  process of blocking.
     794 *
     795 *  @param[in] sync_state is the synchronization state
     796 *  @param[in] the_thread is the thread whose blocking is canceled
     797 *  @param[in] level is the previous ISR disable level
     798 *
     799 *  @note This is a rare routine in RTEMS.  It is called with
     800 *        interrupts disabled and only when an ISR completed
     801 *        a blocking condition in process.
     802 */
     803void _Thread_blocking_operation_Cancel(
     804  Thread_blocking_operation_States  sync_state,
     805  Thread_Control                   *the_thread,
     806  ISR_Level                         level
     807);
     808
    788809#ifndef __RTEMS_APPLICATION__
    789810#include <rtems/score/thread.inl>
  • cpukit/score/include/rtems/score/threadq.h

    rb89f64c r3168deaa  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2006.
     9 *  COPYRIGHT (c) 1989-2008.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    179179 *  priority discipline.
    180180 */
    181 void _Thread_queue_Enqueue_priority(
    182   Thread_queue_Control *the_thread_queue,
    183   Thread_Control       *the_thread
     181Thread_blocking_operation_States _Thread_queue_Enqueue_priority (
     182  Thread_queue_Control *the_thread_queue,
     183  Thread_Control       *the_thread,
     184  ISR_Level            *level_p
    184185);
    185186
     
    231232 *  FIFO discipline.
    232233 */
    233 void _Thread_queue_Enqueue_fifo(
    234   Thread_queue_Control *the_thread_queue,
    235   Thread_Control       *the_thread
     234Thread_blocking_operation_States _Thread_queue_Enqueue_fifo (
     235  Thread_queue_Control *the_thread_queue,
     236  Thread_Control       *the_thread,
     237  ISR_Level            *level_p
    236238);
    237239
  • cpukit/score/include/rtems/score/tqdata.h

    rb89f64c r3168deaa  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2006.
     9 *  COPYRIGHT (c) 1989-2008.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    3636#include <rtems/score/priority.h>
    3737#include <rtems/score/states.h>
     38#include <rtems/score/threadsync.h>
    3839
    3940/**
     
    4546  THREAD_QUEUE_DISCIPLINE_PRIORITY  /* PRIORITY queue discipline */
    4647}   Thread_queue_Disciplines;
    47 
    48 /**
    49  *  The following enumerated types indicate what happened while the thread
    50  *  queue was in the synchronization window.
    51  */
    52 typedef enum {
    53   THREAD_QUEUE_SYNCHRONIZED,
    54   THREAD_QUEUE_NOTHING_HAPPENED,
    55   THREAD_QUEUE_TIMEOUT,
    56   THREAD_QUEUE_SATISFIED
    57 }  Thread_queue_States;
    5848
    5949/**
     
    10090  } Queues;
    10191  /** This field is used to manage the critical section. */
    102   Thread_queue_States      sync_state;
     92  Thread_blocking_operation_States sync_state;
    10393  /** This field indicates the thread queue's blocking discipline. */
    10494  Thread_queue_Disciplines discipline;
  • cpukit/score/inline/rtems/score/threadq.inl

    rb89f64c r3168deaa  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2006.
     9 *  COPYRIGHT (c) 1989-2008.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    5656   */
    5757
    58   if ( the_thread_queue->sync_state != THREAD_QUEUE_SYNCHRONIZED &&
     58  if ( the_thread_queue->sync_state != THREAD_BLOCKING_OPERATION_SYNCHRONIZED &&
    5959       _Thread_Is_executing( the_thread ) ) {
    60     if ( the_thread_queue->sync_state != THREAD_QUEUE_SATISFIED )
    61       the_thread_queue->sync_state = THREAD_QUEUE_TIMEOUT;
     60    if ( the_thread_queue->sync_state != THREAD_BLOCKING_OPERATION_SATISFIED ) {
     61      the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status;
     62      the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_TIMEOUT;
     63    }
    6264  } else {
    6365    the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status;
  • cpukit/score/inline/rtems/score/tqdata.inl

    rb89f64c r3168deaa  
    77
    88/*
    9  *  COPYRIGHT (c) 1989-2006.
     9 *  COPYRIGHT (c) 1989-2008.
    1010 *  On-Line Applications Research Corporation (OAR).
    1111 *
     
    5959)
    6060{
    61   the_thread_queue->sync_state = THREAD_QUEUE_NOTHING_HAPPENED;
     61  the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    6262}
    6363
  • cpukit/score/preinstall.am

    rb89f64c r3168deaa  
    131131        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threadq.h
    132132PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threadq.h
     133
     134$(PROJECT_INCLUDE)/rtems/score/threadsync.h: include/rtems/score/threadsync.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     135        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threadsync.h
     136PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threadsync.h
    133137
    134138$(PROJECT_INCLUDE)/rtems/score/timespec.h: include/rtems/score/timespec.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
  • cpukit/score/src/threadq.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    4848)
    4949{
    50   uint32_t   index;
    51 
    5250  the_thread_queue->state          = state;
    5351  the_thread_queue->discipline     = the_discipline;
    5452  the_thread_queue->timeout_status = timeout_status;
    55   the_thread_queue->sync_state     = THREAD_QUEUE_SYNCHRONIZED;
     53  the_thread_queue->sync_state     = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
    5654
    57   switch ( the_discipline ) {
    58     case THREAD_QUEUE_DISCIPLINE_FIFO:
    59       _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo );
    60       break;
    61     case THREAD_QUEUE_DISCIPLINE_PRIORITY:
    62       for( index=0 ;
    63            index < TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS ;
    64            index++)
    65         _Chain_Initialize_empty( &the_thread_queue->Queues.Priority[index] );
    66       break;
     55  if ( the_discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) {
     56    uint32_t   index;
     57
     58    for( index=0 ;
     59         index < TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS ;
     60         index++)
     61      _Chain_Initialize_empty( &the_thread_queue->Queues.Priority[index] );
     62  } else { /* must be THREAD_QUEUE_DISCIPLINE_FIFO */
     63    _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo );
    6764  }
    6865
  • cpukit/score/src/threadqdequeue.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    4848)
    4949{
    50   Thread_Control *the_thread;
     50  Thread_Control *(*dequeue_p)( Thread_queue_Control * );
    5151
    52   switch ( the_thread_queue->discipline ) {
    53     case THREAD_QUEUE_DISCIPLINE_FIFO:
    54       the_thread = _Thread_queue_Dequeue_fifo( the_thread_queue );
    55       break;
    56     case THREAD_QUEUE_DISCIPLINE_PRIORITY:
    57       the_thread = _Thread_queue_Dequeue_priority( the_thread_queue );
    58       break;
    59     default:              /* this is only to prevent warnings */
    60       the_thread = NULL;
    61       break;
    62   }
     52  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY )
     53    dequeue_p = _Thread_queue_Dequeue_priority;
     54  else /* must be THREAD_QUEUE_DISCIPLINE_FIFO */
     55    dequeue_p = _Thread_queue_Dequeue_fifo;
    6356
    64   return( the_thread );
     57  return (*dequeue_p)( the_thread_queue );
    6558}
  • cpukit/score/src/threadqdequeuefifo.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-2006.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    7676
    7777  switch ( the_thread_queue->sync_state ) {
    78     case THREAD_QUEUE_SYNCHRONIZED:
    79     case THREAD_QUEUE_SATISFIED:
     78    case THREAD_BLOCKING_OPERATION_SYNCHRONIZED:
     79    case THREAD_BLOCKING_OPERATION_SATISFIED:
    8080      _ISR_Enable( level );
    8181      return NULL;
    8282
    83     case THREAD_QUEUE_NOTHING_HAPPENED:
    84     case THREAD_QUEUE_TIMEOUT:
    85       the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED;
     83    case THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED:
     84    case THREAD_BLOCKING_OPERATION_TIMEOUT:
     85      the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SATISFIED;
    8686      _ISR_Enable( level );
    8787      return _Thread_Executing;
  • cpukit/score/src/threadqdequeuepriority.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-2006.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    5656  Chain_Node     *next_node;
    5757  Chain_Node     *previous_node;
     58  Thread_blocking_operation_States sync;
    5859
    5960  _ISR_Disable( level );
     
    6869  }
    6970
    70   switch ( the_thread_queue->sync_state ) {
    71     case THREAD_QUEUE_SYNCHRONIZED:
    72     case THREAD_QUEUE_SATISFIED:
    73       _ISR_Enable( level );
    74       return NULL;
     71  /*
     72   * If we interrupted a blocking operation, cancel it.
     73   */
     74  sync = the_thread_queue->sync_state;
     75  if ( (sync == THREAD_BLOCKING_OPERATION_SYNCHRONIZED) ||
     76       (sync == THREAD_BLOCKING_OPERATION_SATISFIED) ) {
     77    _ISR_Enable( level );
     78    return NULL;
     79  }
    7580
    76     case THREAD_QUEUE_NOTHING_HAPPENED:
    77     case THREAD_QUEUE_TIMEOUT:
    78       the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED;
    79       _ISR_Enable( level );
    80       return _Thread_Executing;
     81  if ( (sync == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ||
     82       (sync == THREAD_BLOCKING_OPERATION_TIMEOUT ) ) {
     83    the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SATISFIED;
     84    _ISR_Enable( level );
     85    return _Thread_Executing;
    8186  }
    8287
  • cpukit/score/src/threadqenqueue.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-2006.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    5252)
    5353{
    54   Thread_Control *the_thread;
     54  Thread_Control                   *the_thread;
     55  ISR_Level                         level;
     56  Thread_blocking_operation_States  sync_state;
     57  Thread_blocking_operation_States (*enqueue_p)(
     58    Thread_queue_Control *,
     59    Thread_Control *,
     60    ISR_Level *
     61  );
    5562
    5663  the_thread = _Thread_Executing;
     
    8390   *  Now enqueue the thread per the discipline for this thread queue.
    8491   */
    85   switch( the_thread_queue->discipline ) {
    86     case THREAD_QUEUE_DISCIPLINE_FIFO:
    87       _Thread_queue_Enqueue_fifo( the_thread_queue, the_thread );
    88       break;
    89     case THREAD_QUEUE_DISCIPLINE_PRIORITY:
    90       _Thread_queue_Enqueue_priority( the_thread_queue, the_thread );
    91       break;
    92   }
     92  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY )
     93    enqueue_p = _Thread_queue_Enqueue_priority;
     94  else /* must be THREAD_QUEUE_DISCIPLINE_FIFO */
     95    enqueue_p = _Thread_queue_Enqueue_fifo;
     96
     97  sync_state = (*enqueue_p)( the_thread_queue, the_thread, &level );
     98  if ( sync_state != THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED )
     99    _Thread_blocking_operation_Cancel( sync_state, the_thread, level );
    93100}
  • cpukit/score/src/threadqenqueuefifo.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    4242 */
    4343
    44 void _Thread_queue_Enqueue_fifo (
     44Thread_blocking_operation_States _Thread_queue_Enqueue_fifo (
    4545  Thread_queue_Control *the_thread_queue,
    46   Thread_Control       *the_thread
     46  Thread_Control       *the_thread,
     47  ISR_Level            *level_p
    4748)
    4849{
    49   ISR_Level            level;
    50   Thread_queue_States  sync_state;
     50  Thread_blocking_operation_States sync_state;
     51  ISR_Level                        level;
    5152
    5253  _ISR_Disable( level );
    5354
    54   sync_state = the_thread_queue->sync_state;
    55   the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
    56 
    57   switch ( sync_state ) {
    58     case THREAD_QUEUE_SYNCHRONIZED:
    59       /*
    60        *  This should never happen.  It indicates that someone did not
    61        *  enter a thread queue critical section.
    62        */
    63       break;
    64 
    65     case THREAD_QUEUE_NOTHING_HAPPENED:
     55    sync_state = the_thread_queue->sync_state;
     56    the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
     57    if (sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) {
    6658      _Chain_Append_unprotected(
    6759        &the_thread_queue->Queues.Fifo,
     
    6961      );
    7062      the_thread->Wait.queue = the_thread_queue;
     63
     64      the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
    7165      _ISR_Enable( level );
    72       return;
    73 
    74     case THREAD_QUEUE_TIMEOUT:
    75       the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status;
    76       the_thread->Wait.queue = NULL;
    77       _ISR_Enable( level );
    78       break;
    79 
    80     case THREAD_QUEUE_SATISFIED:
    81       if ( _Watchdog_Is_active( &the_thread->Timer ) ) {
    82         _Watchdog_Deactivate( &the_thread->Timer );
    83       the_thread->Wait.queue = NULL;
    84         _ISR_Enable( level );
    85         (void) _Watchdog_Remove( &the_thread->Timer );
    86       } else
    87         _ISR_Enable( level );
    88       break;
    89   }
    90 
     66      return THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
     67    }
     68     
    9169  /*
    92    *  Global objects with thread queue's should not be operated on from an
    93    *  ISR.  But the sync code still must allow short timeouts to be processed
    94    *  correctly.
     70   *  An interrupt completed the thread's blocking request.
     71   *  For example, the blocking thread could have been given
     72   *  the mutex by an ISR or timed out.
     73   *
     74   *  WARNING! Returning with interrupts disabled!
    9575   */
    96 
    97   _Thread_Unblock( the_thread );
    98 
    99 #if defined(RTEMS_MULTIPROCESSING)
    100   if ( !_Objects_Is_local_id( the_thread->Object.id ) )
    101     _Thread_MP_Free_proxy( the_thread );
    102 #endif
    103 
     76  *level_p = level;
     77  return sync_state;
    10478}
  • cpukit/score/src/threadqenqueuepriority.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    4343 */
    4444
    45 void _Thread_queue_Enqueue_priority(
     45Thread_blocking_operation_States _Thread_queue_Enqueue_priority (
    4646  Thread_queue_Control *the_thread_queue,
    47   Thread_Control       *the_thread
     47  Thread_Control       *the_thread,
     48  ISR_Level            *level_p
    4849)
    4950{
     
    5960  Priority_Control     priority;
    6061  States_Control       block_state;
    61   Thread_queue_States  sync_state;
    6262
    6363  _Chain_Initialize_empty( &the_thread->Wait.Block2n );
     
    9797  }
    9898
    99   if ( the_thread_queue->sync_state != THREAD_QUEUE_NOTHING_HAPPENED )
     99  if ( the_thread_queue->sync_state !=
     100       THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED )
    100101    goto synchronize;
    101102
    102   the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
     103  the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
    103104
    104105  if ( priority == search_priority )
     
    115116  the_thread->Wait.queue = the_thread_queue;
    116117  _ISR_Enable( level );
    117   return;
     118  return THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    118119
    119120restart_reverse_search:
     
    143144  }
    144145
    145   if ( the_thread_queue->sync_state != THREAD_QUEUE_NOTHING_HAPPENED )
     146  if ( the_thread_queue->sync_state !=
     147       THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED )
    146148    goto synchronize;
    147149
    148   the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
     150  the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
    149151
    150152  if ( priority == search_priority )
     
    161163  the_thread->Wait.queue = the_thread_queue;
    162164  _ISR_Enable( level );
    163   return;
     165  return THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    164166
    165167equal_priority:               /* add at end of priority group */
     
    174176  the_thread->Wait.queue = the_thread_queue;
    175177  _ISR_Enable( level );
    176   return;
     178  return THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
    177179
    178180synchronize:
    179 
    180   sync_state = the_thread_queue->sync_state;
    181   the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
    182 
    183   switch ( sync_state ) {
    184     case THREAD_QUEUE_SYNCHRONIZED:
    185       /*
    186        *  This should never happen.  It indicates that someone did not
    187        *  enter a thread queue critical section.
    188        */
    189       break;
    190 
    191     case THREAD_QUEUE_NOTHING_HAPPENED:
    192       /*
    193        *  This should never happen.  All of this was dealt with above.
    194        */
    195       break;
    196 
    197     case THREAD_QUEUE_TIMEOUT:
    198       the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status;
    199       the_thread->Wait.queue = NULL;
    200       _ISR_Enable( level );
    201       break;
    202 
    203     case THREAD_QUEUE_SATISFIED:
    204       if ( _Watchdog_Is_active( &the_thread->Timer ) ) {
    205         _Watchdog_Deactivate( &the_thread->Timer );
    206         the_thread->Wait.queue = NULL;
    207         _ISR_Enable( level );
    208         (void) _Watchdog_Remove( &the_thread->Timer );
    209       } else
    210         _ISR_Enable( level );
    211       break;
    212   }
    213 
    214181  /*
    215    *  Global objects with thread queue's should not be operated on from an
    216    *  ISR.  But the sync code still must allow short timeouts to be processed
    217    *  correctly.
     182   *  An interrupt completed the thread's blocking request.
     183   *  For example, the blocking thread could have been given
     184   *  the mutex by an ISR or timed out.
     185   *
     186   *  WARNING! Returning with interrupts disabled!
    218187   */
    219 
    220   _Thread_Unblock( the_thread );
    221 
    222 #if defined(RTEMS_MULTIPROCESSING)
    223   if ( !_Objects_Is_local_id( the_thread->Object.id ) )
    224     _Thread_MP_Free_proxy( the_thread );
    225 #endif
     188  *level_p = level;
     189  return the_thread_queue->sync_state;
    226190}
  • cpukit/score/src/threadqextract.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
  • cpukit/score/src/threadqextractfifo.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-2006.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
  • cpukit/score/src/threadqextractpriority.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-2006.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
  • cpukit/score/src/threadqextractwithproxy.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
  • cpukit/score/src/threadqfirst.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
  • cpukit/score/src/threadqfirstfifo.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
  • cpukit/score/src/threadqfirstpriority.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
  • cpukit/score/src/threadqflush.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
  • cpukit/score/src/threadqrequeue.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-2006.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    4747)
    4848{
    49   /* just in case the thread really wasn't blocked here */
    50   if ( !the_thread_queue ) {
     49  /*
     50   * Just in case the thread really wasn't blocked on a thread queue
     51   * when we get here.
     52   */
     53  if ( !the_thread_queue )
    5154    return;
    52   }
    5355
    54   switch ( the_thread_queue->discipline ) {
    55     case THREAD_QUEUE_DISCIPLINE_FIFO:
    56       /* queueing by FIFO -- nothing to do */
    57       break;
    58     case THREAD_QUEUE_DISCIPLINE_PRIORITY: {
    59       Thread_queue_Control *tq = the_thread_queue;
    60       ISR_Level             level;
     56  /*
     57   * If queueing by FIFO, there is nothing to do. This only applies to
     58   * priority blocking discipline.
     59   */
     60  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) {
     61    Thread_queue_Control *tq = the_thread_queue;
     62    ISR_Level             level;
     63    ISR_Level             level_ignored;
    6164
    62       _ISR_Disable( level );
    63       if ( _States_Is_waiting_on_thread_queue( the_thread->current_state ) ) {
    64         _Thread_queue_Enter_critical_section( tq );
    65         _Thread_queue_Extract_priority_helper( tq, the_thread, TRUE );
    66         _Thread_queue_Enqueue_priority( tq, the_thread );
    67       }
    68       _ISR_Enable( level );
    69       break;
     65    _ISR_Disable( level );
     66    if ( _States_Is_waiting_on_thread_queue( the_thread->current_state ) ) {
     67      _Thread_queue_Enter_critical_section( tq );
     68      _Thread_queue_Extract_priority_helper( tq, the_thread, TRUE );
     69      (void) _Thread_queue_Enqueue_priority( tq, the_thread, &level_ignored );
    7070    }
     71    _ISR_Enable( level );
    7172  }
    7273}
  • cpukit/score/src/threadqtimeout.c

    rb89f64c r3168deaa  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-2007.
     5 *  COPYRIGHT (c) 1989-2008.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
Note: See TracChangeset for help on using the changeset viewer.