RTEMS: cpukit/include/rtems/score/schedulernodeimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
schedulernodeimpl.h
Go to the documentation of this file.
1
9/*
10 * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved.
11 *
12 * embedded brains GmbH
13 * Dornierstr. 4
14 * 82178 Puchheim
15 * Germany
16 * <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#ifndef _RTEMS_SCORE_SCHEDULERNODEIMPL_H
24#define _RTEMS_SCORE_SCHEDULERNODEIMPL_H
25
26#include <rtems/score/schedulernode.h>
27#include <rtems/score/priorityimpl.h>
28
35struct _Scheduler_Control;
36
37#ifdef __cplusplus
38extern "C" {
39#endif /* __cplusplus */
40
41#define SCHEDULER_NODE_OF_WAIT_PRIORITY_NODE( node ) \
42 RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority.Node.Node.Chain )
43
44#define SCHEDULER_NODE_OF_WAIT_PRIORITY( node ) \
45 RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority )
46
51#define SCHEDULER_PRIORITY_APPEND_FLAG 1
52
56#define SCHEDULER_PRIORITY_MAP( priority ) ( ( priority ) << 1 )
57
61#define SCHEDULER_PRIORITY_UNMAP( priority ) ( ( priority ) >> 1 )
62
66#define SCHEDULER_PRIORITY_PURIFY( priority ) \
67 ( ( priority ) & ~( (Priority_Control) SCHEDULER_PRIORITY_APPEND_FLAG ) )
68
72#define SCHEDULER_PRIORITY_APPEND( priority ) \
73 ( ( priority ) | SCHEDULER_PRIORITY_APPEND_FLAG )
74
80#define SCHEDULER_PRIORITY_IS_APPEND( priority ) \
81 ( ( ( priority ) & SCHEDULER_PRIORITY_APPEND_FLAG ) != 0 )
82
91 RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(
92 const struct _Scheduler_Control *scheduler,
93 Scheduler_Node *node,
94 Thread_Control *the_thread,
95 Priority_Control priority
96)
97{
98 node->owner = the_thread;
99
100 node->Priority.value = priority;
101
102#if defined(RTEMS_SMP)
103 _Chain_Initialize_node( &node->Thread.Wait_node );
104 node->Wait.Priority.scheduler = scheduler;
105 node->user = the_thread;
106 node->idle = NULL;
107 _SMP_sequence_lock_Initialize( &node->Priority.Lock );
108#else
109 (void) scheduler;
110 (void) the_thread;
111#endif
112}
113
121 RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Node_get_scheduler(
122 const Scheduler_Node *node
123)
124{
125 return _Priority_Get_scheduler( &node->Wait.Priority );
126}
127
135 RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner(
136 const Scheduler_Node *node
137)
138{
139 return node->owner;
140}
141
149 RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority(
150 Scheduler_Node *node
151)
152{
153 Priority_Control priority;
154
155#if defined(RTEMS_SMP)
156 unsigned int seq;
157
158 do {
159 seq = _SMP_sequence_lock_Read_begin( &node->Priority.Lock );
160#endif
161
162 priority = node->Priority.value;
163
164#if defined(RTEMS_SMP)
165 } while ( _SMP_sequence_lock_Read_retry( &node->Priority.Lock, seq ) );
166#endif
167
168 return priority;
169}
170
178 RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority(
179 Scheduler_Node *node,
180 Priority_Control new_priority,
181 bool prepend_it
182)
183{
184#if defined(RTEMS_SMP)
185 unsigned int seq;
186
187 seq = _SMP_sequence_lock_Write_begin( &node->Priority.Lock );
188#endif
189
190 new_priority |= ( prepend_it ? 0 : SCHEDULER_PRIORITY_APPEND_FLAG );
191 node->Priority.value = new_priority;
192
193#if defined(RTEMS_SMP)
194 _SMP_sequence_lock_Write_end( &node->Priority.Lock, seq );
195#endif
196}
197
198#if defined(RTEMS_SMP)
206 RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user(
207 const Scheduler_Node *node
208)
209{
210 return node->user;
211}
212
219 RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user(
220 Scheduler_Node *node,
221 Thread_Control *user
222)
223{
224 node->user = user;
225}
226
234 RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle(
235 const Scheduler_Node *node
236)
237{
238 return node->idle;
239}
240#endif
241
242#ifdef __cplusplus
243}
244#endif /* __cplusplus */
245
248#endif /* _RTEMS_SCORE_SCHEDULERNODEIMPL_H */
NULL
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Chain_Initialize_node
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:122
Priority_Control
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
_Priority_Get_scheduler
RTEMS_INLINE_ROUTINE const Scheduler_Control * _Priority_Get_scheduler(const Priority_Aggregation *aggregation)
Gets the priority aggregation's scheduler.
Definition: priorityimpl.h:284
_Scheduler_Node_do_initialize
RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(const struct _Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, Priority_Control priority)
Initializes a node.
Definition: schedulernodeimpl.h:91
_Scheduler_Node_get_owner
RTEMS_INLINE_ROUTINE Thread_Control * _Scheduler_Node_get_owner(const Scheduler_Node *node)
Gets the owner of the node.
Definition: schedulernodeimpl.h:135
SCHEDULER_PRIORITY_APPEND_FLAG
#define SCHEDULER_PRIORITY_APPEND_FLAG
Priority append indicator for the priority control used for the scheduler node priority.
Definition: schedulernodeimpl.h:51
_Scheduler_Node_get_scheduler
RTEMS_INLINE_ROUTINE const Scheduler_Control * _Scheduler_Node_get_scheduler(const Scheduler_Node *node)
Gets the scheduler of the node.
Definition: schedulernodeimpl.h:121
_Scheduler_Node_get_priority
RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority(Scheduler_Node *node)
Gets the priority of the node.
Definition: schedulernodeimpl.h:149
_Scheduler_Node_set_priority
RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority(Scheduler_Node *node, Priority_Control new_priority, bool prepend_it)
Sets the priority of the node.
Definition: schedulernodeimpl.h:178
schedulernode.h
Handles Scheduler Nodes.
priorityimpl.h
Priority Handler API Implementation.
Scheduler_Node
Scheduler node for per-thread data.
Definition: schedulernode.h:79
Scheduler_Node::owner
struct _Thread_Control * owner
The thread owning this node.
Definition: schedulernode.h:123
Scheduler_Node::Wait
struct Scheduler_Node::@3981 Wait
Thread wait support block.
_Scheduler_Control
Scheduler control.
Definition: scheduler.h:269
_Thread_Control
Definition: thread.h:732