Changeset 688fbc44 in rtems


Ignore:
Timestamp:
Mar 22, 2015, 9:43:06 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
d2bdf5c
Parents:
2429766
git-author:
Sebastian Huber <sebastian.huber@…> (03/22/15 09:43:06)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/22/15 10:56:43)
Message:

score: Move _Thread_queue_Extract()

Move _Thread_queue_Dequeue(). We need all or no thread queue functions
so it makes no sense to have them in separate modules. One module
enables compiler optimizations without link-time optimization. Make
_Thread_blocking_operation_Finalize() static since it is use now only in
one module.

Location:
cpukit/score
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    r2429766 r688fbc44  
    298298
    299299## THREADQ_C_FILES
    300 libscore_a_SOURCES += src/threadq.c src/threadqdequeue.c \
    301     src/threadqenqueue.c src/threadqextract.c src/threadqrequeue.c \
     300libscore_a_SOURCES += src/threadq.c \
     301    src/threadqenqueue.c src/threadqrequeue.c \
    302302    src/threadqextractwithproxy.c src/threadqfirst.c \
    303303    src/threadqflush.c src/threadqprocesstimeout.c src/threadqtimeout.c
  • cpukit/score/include/rtems/score/threadimpl.h

    r2429766 r688fbc44  
    417417 */
    418418Thread_Control *_Thread_Acquire_executing( ISR_lock_Context *lock_context );
    419 
    420 /**
    421  *  @brief Finalize a blocking operation.
    422  *
    423  *  This method is used to finalize a blocking operation that was
    424  *  satisfied. It may be used with thread queues or any other synchronization
    425  *  object that uses the blocking states and watchdog times for timeout.
    426  *
    427  *  This method will restore the previous ISR disable level during the cancel
    428  *  operation.  Thus it is an implicit _ISR_Enable().
    429  *
    430  *  @param[in] the_thread is the thread whose blocking is canceled
    431  *  @param[in] level is the previous ISR disable level
    432  */
    433 void _Thread_blocking_operation_Finalize(
    434   Thread_Control                   *the_thread,
    435   ISR_Level                         level
    436 );
    437419
    438420RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU(
  • cpukit/score/src/threadqenqueue.c

    r2429766 r688fbc44  
    22 * @file
    33 *
    4  * @brief Thread Queue Enqueue
     4 * @brief Thread Queue Operations
    55 * @ingroup ScoreThreadQ
    66 */
     
    2121#include <rtems/score/threadqimpl.h>
    2222#include <rtems/score/isrlevel.h>
     23#include <rtems/score/rbtreeimpl.h>
    2324#include <rtems/score/threadimpl.h>
    2425#include <rtems/score/watchdogimpl.h>
    2526
    26 void _Thread_blocking_operation_Finalize(
     27/**
     28 *  @brief Finalize a blocking operation.
     29 *
     30 *  This method is used to finalize a blocking operation that was
     31 *  satisfied. It may be used with thread queues or any other synchronization
     32 *  object that uses the blocking states and watchdog times for timeout.
     33 *
     34 *  This method will restore the previous ISR disable level during the cancel
     35 *  operation.  Thus it is an implicit _ISR_Enable().
     36 *
     37 *  @param[in] the_thread is the thread whose blocking is canceled
     38 *  @param[in] level is the previous ISR disable level
     39 */
     40static void _Thread_blocking_operation_Finalize(
    2741  Thread_Control                   *the_thread,
    2842  ISR_Level                         level
     
    183197  }
    184198}
     199
     200void _Thread_queue_Extract_with_return_code(
     201  Thread_queue_Control *the_thread_queue,
     202  Thread_Control       *the_thread,
     203  uint32_t              return_code
     204)
     205{
     206  ISR_Level level;
     207
     208  _ISR_Disable( level );
     209
     210  if ( !_States_Is_waiting_on_thread_queue( the_thread->current_state ) ) {
     211    _ISR_Enable( level );
     212    return;
     213  }
     214
     215  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_FIFO ) {
     216    _Chain_Extract_unprotected( &the_thread->Object.Node );
     217  } else { /* must be THREAD_QUEUE_DISCIPLINE_PRIORITY */
     218    _RBTree_Extract(
     219      &the_thread->Wait.queue->Queues.Priority,
     220      &the_thread->RBNode
     221    );
     222  }
     223
     224  the_thread->Wait.return_code = return_code;
     225
     226  /*
     227   * We found a thread to unblock.
     228   *
     229   * NOTE: This is invoked with interrupts still disabled.
     230   */
     231  _Thread_blocking_operation_Finalize( the_thread, level );
     232}
     233
     234void _Thread_queue_Extract(
     235  Thread_queue_Control *the_thread_queue,
     236  Thread_Control       *the_thread
     237)
     238{
     239  _Thread_queue_Extract_with_return_code(
     240    the_thread_queue,
     241    the_thread,
     242    the_thread->Wait.return_code
     243  );
     244}
     245
     246Thread_Control *_Thread_queue_Dequeue(
     247  Thread_queue_Control *the_thread_queue
     248)
     249{
     250  Thread_Control *the_thread;
     251  ISR_Level       level;
     252  Thread_blocking_operation_States  sync_state;
     253
     254  the_thread = NULL;
     255  _ISR_Disable( level );
     256
     257  /*
     258   * Invoke the discipline specific dequeue method.
     259   */
     260  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_FIFO ) {
     261    if ( !_Chain_Is_empty( &the_thread_queue->Queues.Fifo ) ) {
     262      the_thread = (Thread_Control *)
     263       _Chain_Get_first_unprotected( &the_thread_queue->Queues.Fifo );
     264    }
     265  } else { /* must be THREAD_QUEUE_DISCIPLINE_PRIORITY */
     266    RBTree_Node    *first;
     267
     268    first = _RBTree_Get( &the_thread_queue->Queues.Priority, RBT_LEFT );
     269    if ( first ) {
     270      the_thread = THREAD_RBTREE_NODE_TO_THREAD( first );
     271    }
     272  }
     273
     274  if ( the_thread == NULL ) {
     275    /*
     276     * We did not find a thread to unblock in the queue.  Maybe the executing
     277     * thread is about to block on this thread queue.
     278     */
     279    sync_state = the_thread_queue->sync_state;
     280    if ( (sync_state == THREAD_BLOCKING_OPERATION_TIMEOUT) ||
     281         (sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) {
     282      the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SATISFIED;
     283      the_thread = _Thread_Executing;
     284    } else {
     285      _ISR_Enable( level );
     286      return NULL;
     287    }
     288  }
     289
     290  /*
     291   * We found a thread to unblock.
     292   *
     293   * NOTE: This is invoked with interrupts still disabled.
     294   */
     295  _Thread_blocking_operation_Finalize( the_thread, level );
     296
     297  return the_thread;
     298}
Note: See TracChangeset for help on using the changeset viewer.