source: rtems/cpukit/score/src/threadqextract.c @ 3250664

4.115
Last change on this file since 3250664 was 3250664, checked in by Joel Sherrill <joel.sherrill@…>, on 07/15/14 at 17:37:36

Thread Queue: Merge discipline subroutines into main methods

There was a lot of duplication between the discipline subroutines.
With the transition to RBTrees for priority discipline, there were
only a few lines of source code manipulating the data structure
for FIFO and priority. Thus is made sense to fold these back
into the main methods.

As part of doing this all of the tests for discipline were changed
to be in the same order.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Extracts Thread from Thread Queue
5 *
6 * @ingroup ScoreThreadQ
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2014.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/score/chainimpl.h>
23#include <rtems/score/threadimpl.h>
24#include <rtems/score/threadqimpl.h>
25#include <rtems/score/watchdogimpl.h>
26
27void _Thread_queue_Extract_with_return_code(
28  Thread_queue_Control *the_thread_queue,
29  Thread_Control       *the_thread,
30  uint32_t              return_code
31)
32{
33  ISR_Level level;
34
35  _ISR_Disable( level );
36
37  if ( !_States_Is_waiting_on_thread_queue( the_thread->current_state ) ) {
38    _ISR_Enable( level );
39    return;
40  }
41
42  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_FIFO ) {
43    _Chain_Extract_unprotected( &the_thread->Object.Node );
44  } else { /* must be THREAD_QUEUE_DISCIPLINE_PRIORITY */
45    _RBTree_Extract(
46      &the_thread->Wait.queue->Queues.Priority,
47      &the_thread->RBNode
48    );
49  }
50
51  the_thread->Wait.queue = NULL;
52  the_thread->Wait.return_code = return_code;
53
54  if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
55    _ISR_Enable( level );
56  } else {
57    _Watchdog_Deactivate( &the_thread->Timer );
58    _ISR_Enable( level );
59    (void) _Watchdog_Remove( &the_thread->Timer );
60  }
61
62  _Thread_Unblock( the_thread );
63
64#if defined(RTEMS_MULTIPROCESSING)
65  if ( !_Objects_Is_local_id( the_thread->Object.id ) )
66    _Thread_MP_Free_proxy( the_thread );
67#endif
68
69}
70
71void _Thread_queue_Extract(
72  Thread_queue_Control *the_thread_queue,
73  Thread_Control       *the_thread
74)
75{
76  _Thread_queue_Extract_with_return_code(
77    the_thread_queue,
78    the_thread,
79    the_thread->Wait.return_code
80  );
81}
Note: See TracBrowser for help on using the repository browser.