source: rtems/cpukit/score/include/rtems/score/schedulernodeimpl.h @ b5f1b24

Last change on this file since b5f1b24 was b5f1b24, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 31, 2016 at 7:04:07 AM

score: Delete Scheduler_Node::accepts_help

Update #2556.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * Copyright (c) 2014, 2016 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifndef _RTEMS_SCORE_SCHEDULERNODEIMPL_H
16#define _RTEMS_SCORE_SCHEDULERNODEIMPL_H
17
18#include <rtems/score/schedulernode.h>
19#include <rtems/score/priorityimpl.h>
20
21struct Scheduler_Control;
22
23#ifdef __cplusplus
24extern "C" {
25#endif /* __cplusplus */
26
27#define SCHEDULER_NODE_OF_WAIT_PRIORITY_NODE( node ) \
28  RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority.Node.Node.Chain )
29
30#define SCHEDULER_NODE_OF_WAIT_PRIORITY( node ) \
31  RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority )
32
33RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(
34  const struct Scheduler_Control *scheduler,
35  Scheduler_Node                 *node,
36  Thread_Control                 *the_thread,
37  Priority_Control                priority
38)
39{
40  node->owner = the_thread;
41
42  node->Priority.value = priority;
43  node->Priority.prepend_it = false;
44
45#if defined(RTEMS_SMP)
46  _Chain_Initialize_node( &node->Thread.Wait_node );
47  node->Wait.Priority.scheduler = scheduler;
48  node->user = the_thread;
49  node->idle = NULL;
50  _SMP_sequence_lock_Initialize( &node->Priority.Lock );
51#else
52  (void) scheduler;
53  (void) the_thread;
54#endif
55}
56
57RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Node_get_scheduler(
58  const Scheduler_Node *node
59)
60{
61  return _Priority_Get_scheduler( &node->Wait.Priority );
62}
63
64RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner(
65  const Scheduler_Node *node
66)
67{
68  return node->owner;
69}
70
71RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority(
72  Scheduler_Node *node,
73  bool           *prepend_it_p
74)
75{
76  Priority_Control priority;
77  bool             prepend_it;
78
79#if defined(RTEMS_SMP)
80  unsigned int     seq;
81
82  do {
83    seq = _SMP_sequence_lock_Read_begin( &node->Priority.Lock );
84#endif
85
86    priority = node->Priority.value;
87    prepend_it = node->Priority.prepend_it;
88
89#if defined(RTEMS_SMP)
90  } while ( _SMP_sequence_lock_Read_retry( &node->Priority.Lock, seq ) );
91#endif
92
93  *prepend_it_p = prepend_it;
94
95  return priority;
96}
97
98RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority(
99  Scheduler_Node   *node,
100  Priority_Control  new_priority,
101  bool              prepend_it
102)
103{
104#if defined(RTEMS_SMP)
105  unsigned int seq;
106
107  seq = _SMP_sequence_lock_Write_begin( &node->Priority.Lock );
108#endif
109
110  node->Priority.value = new_priority;
111  node->Priority.prepend_it = prepend_it;
112
113#if defined(RTEMS_SMP)
114  _SMP_sequence_lock_Write_end( &node->Priority.Lock, seq );
115#endif
116}
117
118#if defined(RTEMS_SMP)
119RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user(
120  const Scheduler_Node *node
121)
122{
123  return node->user;
124}
125
126RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user(
127  Scheduler_Node *node,
128  Thread_Control *user
129)
130{
131  node->user = user;
132}
133
134RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle(
135  const Scheduler_Node *node
136)
137{
138  return node->idle;
139}
140#endif
141
142#ifdef __cplusplus
143}
144#endif /* __cplusplus */
145
146#endif /* _RTEMS_SCORE_SCHEDULERNODEIMPL_H */
Note: See TracBrowser for help on using the repository browser.