source: rtems/cpukit/score/src/threadqfirst.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.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Thread Queue First
5 *  @ingroup ScoreThreadQ
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/chainimpl.h>
22#include <rtems/score/isrlevel.h>
23#include <rtems/score/threadqimpl.h>
24
25Thread_Control *_Thread_queue_First(
26  Thread_queue_Control *the_thread_queue
27)
28{
29  ISR_Level       level;
30  Thread_Control *thread;
31
32  thread = NULL;
33
34  _ISR_Disable( level );
35
36  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_FIFO ) {
37    if ( !_Chain_Is_empty( &the_thread_queue->Queues.Fifo ) )
38      thread = (Thread_Control *) _Chain_First(&the_thread_queue->Queues.Fifo);
39  } else { /* must be THREAD_QUEUE_DISCIPLINE_PRIORITY */
40    RBTree_Node *first;
41
42    first = _RBTree_First( &the_thread_queue->Queues.Priority, RBT_LEFT );
43    if ( first )
44      thread = _RBTree_Container_of( first, Thread_Control, RBNode );
45  }
46
47  _ISR_Enable( level );
48
49  return thread;
50}
Note: See TracBrowser for help on using the repository browser.