RTEMS  5.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
schedulernodeimpl.h
1 /*
2  * Copyright (c) 2014, 2017 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 
21 struct _Scheduler_Control;
22 
23 #ifdef __cplusplus
24 extern "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 
37 #define SCHEDULER_PRIORITY_APPEND_FLAG 1
38 
39 RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(
40  const struct _Scheduler_Control *scheduler,
41  Scheduler_Node *node,
42  Thread_Control *the_thread,
43  Priority_Control priority
44 )
45 {
46  node->owner = the_thread;
47 
48  node->Priority.value = priority;
49 
50 #if defined(RTEMS_SMP)
51  _Chain_Initialize_node( &node->Thread.Wait_node );
52  node->Wait.Priority.scheduler = scheduler;
53  node->user = the_thread;
54  node->idle = NULL;
55  _SMP_sequence_lock_Initialize( &node->Priority.Lock );
56 #else
57  (void) scheduler;
58  (void) the_thread;
59 #endif
60 }
61 
62 RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Node_get_scheduler(
63  const Scheduler_Node *node
64 )
65 {
66  return _Priority_Get_scheduler( &node->Wait.Priority );
67 }
68 
69 RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner(
70  const Scheduler_Node *node
71 )
72 {
73  return node->owner;
74 }
75 
76 RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority(
77  Scheduler_Node *node
78 )
79 {
80  Priority_Control priority;
81 
82 #if defined(RTEMS_SMP)
83  unsigned int seq;
84 
85  do {
86  seq = _SMP_sequence_lock_Read_begin( &node->Priority.Lock );
87 #endif
88 
89  priority = node->Priority.value;
90 
91 #if defined(RTEMS_SMP)
92  } while ( _SMP_sequence_lock_Read_retry( &node->Priority.Lock, seq ) );
93 #endif
94 
95  return priority;
96 }
97 
98 RTEMS_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  new_priority |= ( prepend_it ? 0 : SCHEDULER_PRIORITY_APPEND_FLAG );
111  node->Priority.value = new_priority;
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)
119 RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user(
120  const Scheduler_Node *node
121 )
122 {
123  return node->user;
124 }
125 
126 RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user(
127  Scheduler_Node *node,
128  Thread_Control *user
129 )
130 {
131  node->user = user;
132 }
133 
134 RTEMS_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 */
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:66
Definition: thread.h:728
struct _Thread_Control * owner
The thread owning this node.
Definition: schedulernode.h:109
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:119
struct Scheduler_Node::@3976 Wait
Thread wait support block.
Scheduler control.
Definition: scheduler.h:266
Scheduler node for per-thread data.
Definition: schedulernode.h:65
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77