source: rtems/cpukit/score/src/threadq.c @ cceb19f4

4.115
Last change on this file since cceb19f4 was 60fe374, checked in by Sebastian Huber <sebastian.huber@…>, on 08/03/14 at 11:02:58

rbtree: Add and use RBTree_Compare_result

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Thread Queue Initialize
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/rbtreeimpl.h>
24#include <rtems/score/scheduler.h>
25#include <rtems/score/threadimpl.h>
26
27RBTree_Compare_result _Thread_queue_Compare_priority(
28  const RBTree_Node *left,
29  const RBTree_Node *right
30)
31{
32  Priority_Control left_priority =
33    THREAD_RBTREE_NODE_TO_THREAD( left )->current_priority;
34  Priority_Control right_priority =
35    THREAD_RBTREE_NODE_TO_THREAD( right )->current_priority;
36
37  /*
38   * SuperCore priorities use lower numbers to indicate greater importance.
39   */
40  if ( left_priority == right_priority )
41    return 0;
42  if ( left_priority < right_priority )
43    return -1;
44  return 1;
45}
46
47void _Thread_queue_Initialize(
48  Thread_queue_Control         *the_thread_queue,
49  Thread_queue_Disciplines      the_discipline,
50  States_Control                state,
51  uint32_t                      timeout_status
52)
53{
54  if ( _Scheduler_FIXME_thread_priority_queues_are_broken ) {
55    the_discipline = THREAD_QUEUE_DISCIPLINE_FIFO;
56  }
57
58  the_thread_queue->state          = state;
59  the_thread_queue->discipline     = the_discipline;
60  the_thread_queue->timeout_status = timeout_status;
61  the_thread_queue->sync_state     = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
62
63  if ( the_discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) {
64    _RBTree_Initialize_empty( &the_thread_queue->Queues.Priority );
65  } else { /* must be THREAD_QUEUE_DISCIPLINE_FIFO */
66    _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo );
67  }
68
69}
Note: See TracBrowser for help on using the repository browser.