source: rtems/cpukit/score/include/rtems/score/schedulernodeimpl.h @ 6771359f

5
Last change on this file since 6771359f was 6771359f, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 27, 2016 at 4:42:06 AM

score: Second part of new MrsP implementation

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  node->accepts_help = the_thread;
51  _SMP_sequence_lock_Initialize( &node->Priority.Lock );
52#else
53  (void) scheduler;
54  (void) the_thread;
55#endif
56}
57
58RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Node_get_scheduler(
59  const Scheduler_Node *node
60)
61{
62  return _Priority_Get_scheduler( &node->Wait.Priority );
63}
64
65RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner(
66  const Scheduler_Node *node
67)
68{
69  return node->owner;
70}
71
72RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority(
73  Scheduler_Node *node,
74  bool           *prepend_it_p
75)
76{
77  Priority_Control priority;
78  bool             prepend_it;
79
80#if defined(RTEMS_SMP)
81  unsigned int     seq;
82
83  do {
84    seq = _SMP_sequence_lock_Read_begin( &node->Priority.Lock );
85#endif
86
87    priority = node->Priority.value;
88    prepend_it = node->Priority.prepend_it;
89
90#if defined(RTEMS_SMP)
91  } while ( _SMP_sequence_lock_Read_retry( &node->Priority.Lock, seq ) );
92#endif
93
94  *prepend_it_p = prepend_it;
95
96  return priority;
97}
98
99RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority(
100  Scheduler_Node   *node,
101  Priority_Control  new_priority,
102  bool              prepend_it
103)
104{
105#if defined(RTEMS_SMP)
106  unsigned int seq;
107
108  seq = _SMP_sequence_lock_Write_begin( &node->Priority.Lock );
109#endif
110
111  node->Priority.value = new_priority;
112  node->Priority.prepend_it = prepend_it;
113
114#if defined(RTEMS_SMP)
115  _SMP_sequence_lock_Write_end( &node->Priority.Lock, seq );
116#endif
117}
118
119#if defined(RTEMS_SMP)
120RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user(
121  const Scheduler_Node *node
122)
123{
124  return node->user;
125}
126
127RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user(
128  Scheduler_Node *node,
129  Thread_Control *user
130)
131{
132  node->user = user;
133}
134
135RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle(
136  const Scheduler_Node *node
137)
138{
139  return node->idle;
140}
141#endif
142
143#ifdef __cplusplus
144}
145#endif /* __cplusplus */
146
147#endif /* _RTEMS_SCORE_SCHEDULERNODEIMPL_H */
Note: See TracBrowser for help on using the repository browser.