source: rtems/cpukit/score/src/threadqfirst.c @ 40dcafa

4.115
Last change on this file since 40dcafa was 40dcafa, checked in by Sebastian Huber <sebastian.huber@…>, on 08/02/14 at 14:22:31

Add and use RTEMS_CONTAINER_OF()

  • Property mode set to 100644
File size: 1.2 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/threadqimpl.h>
22#include <rtems/score/chainimpl.h>
23#include <rtems/score/isrlevel.h>
24#include <rtems/score/threadimpl.h>
25
26Thread_Control *_Thread_queue_First(
27  Thread_queue_Control *the_thread_queue
28)
29{
30  ISR_Level       level;
31  Thread_Control *thread;
32
33  thread = NULL;
34
35  _ISR_Disable( level );
36
37  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_FIFO ) {
38    if ( !_Chain_Is_empty( &the_thread_queue->Queues.Fifo ) )
39      thread = (Thread_Control *) _Chain_First(&the_thread_queue->Queues.Fifo);
40  } else { /* must be THREAD_QUEUE_DISCIPLINE_PRIORITY */
41    RBTree_Node *first;
42
43    first = _RBTree_First( &the_thread_queue->Queues.Priority, RBT_LEFT );
44    if ( first )
45      thread = THREAD_RBTREE_NODE_TO_THREAD( first );
46  }
47
48  _ISR_Enable( level );
49
50  return thread;
51}
Note: See TracBrowser for help on using the repository browser.