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

5
Last change on this file since b5f1b24 was b5f1b24, checked in by Sebastian Huber <sebastian.huber@…>, on 10/31/16 at 07:04:07

score: Delete Scheduler_Node::accepts_help

Update #2556.

  • Property mode set to 100644
File size: 5.7 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_SCHEDULERNODE_H
16#define _RTEMS_SCORE_SCHEDULERNODE_H
17
18#include <rtems/score/basedefs.h>
19#include <rtems/score/chain.h>
20#include <rtems/score/priority.h>
21#include <rtems/score/smplockseq.h>
22
23struct _Thread_Control;
24
25#ifdef __cplusplus
26extern "C" {
27#endif /* __cplusplus */
28
29#if defined(RTEMS_SMP)
30/**
31 * @brief The scheduler node requests.
32 */
33typedef enum {
34  /**
35   * @brief The scheduler node is not on the list of pending requests.
36   */
37  SCHEDULER_NODE_REQUEST_NOT_PENDING,
38
39  /**
40   * @brief There is a pending scheduler node request to add this scheduler
41   * node to the Thread_Control::Scheduler::Scheduler_nodes chain.
42   */
43  SCHEDULER_NODE_REQUEST_ADD,
44
45  /**
46   * @brief There is a pending scheduler node request to remove this scheduler
47   * node from the Thread_Control::Scheduler::Scheduler_nodes chain.
48   */
49  SCHEDULER_NODE_REQUEST_REMOVE,
50
51  /**
52   * @brief The scheduler node is on the list of pending requests, but nothing
53   * should change.
54   */
55  SCHEDULER_NODE_REQUEST_NOTHING,
56
57} Scheduler_Node_request;
58#endif
59
60typedef struct Scheduler_Node Scheduler_Node;
61
62/**
63 * @brief Scheduler node for per-thread data.
64 */
65struct Scheduler_Node {
66#if defined(RTEMS_SMP)
67  /**
68   * @brief Chain node for usage in various scheduler data structures.
69   *
70   * Strictly this is the wrong place for this field since the data structures
71   * to manage scheduler nodes belong to the particular scheduler
72   * implementation.  Currently all SMP scheduler implementations use chains.
73   * The node is here to simplify things, just like the object node in the
74   * thread control block.  It may be replaced with a union to add a red-black
75   * tree node in the future.
76   */
77  Chain_Node Node;
78
79  /**
80   * @brief The sticky level determines if this scheduler node should use an
81   * idle thread in case this node is scheduled and the owner thread is
82   * blocked.
83   */
84  int sticky_level;
85
86  /**
87   * @brief The thread using this node.
88   *
89   * This is either the owner or an idle thread.
90   */
91  struct _Thread_Control *user;
92
93  /**
94   * @brief The idle thread claimed by this node in case the sticky level is
95   * greater than zero and the thread is block or is scheduled on another
96   * scheduler instance.
97   *
98   * This is necessary to ensure the priority ceiling protocols work across
99   * scheduler boundaries.
100   */
101  struct _Thread_Control *idle;
102#endif
103
104  /**
105   * @brief The thread owning this node.
106   */
107  struct _Thread_Control *owner;
108
109#if defined(RTEMS_SMP)
110  /**
111   * @brief Block to register and manage this scheduler node in the thread
112   * control block of the owner of this scheduler node.
113   */
114  struct {
115    /**
116     * @brief Node to add this scheduler node to
117     * Thread_Control::Scheduler::Wait_nodes.
118     */
119    Chain_Node Wait_node;
120
121    /**
122     * @brief Node to add this scheduler node to
123     * Thread_Control::Scheduler::Scheduler_nodes or a temporary remove list.
124     */
125    union {
126      /**
127       * @brief The node for Thread_Control::Scheduler::Scheduler_nodes.
128       */
129      Chain_Node Chain;
130
131      /**
132       * @brief The next pointer for a temporary remove list.
133       *
134       * @see _Thread_Scheduler_process_requests().
135       */
136      Scheduler_Node *next;
137    } Scheduler_node;
138
139    /**
140     * @brief Link to the next scheduler node in the
141     * Thread_Control::Scheduler::requests list.
142     */
143    Scheduler_Node *next_request;
144
145    /**
146     * @brief The current scheduler node request.
147     */
148    Scheduler_Node_request request;
149  } Thread;
150#endif
151
152  /**
153   * @brief Thread wait support block.
154   */
155  struct {
156    Priority_Aggregation Priority;
157  } Wait;
158
159  /**
160   * @brief The thread priority information used by the scheduler.
161   *
162   * The thread priority is manifest in two independent areas.  One area is the
163   * user visible thread priority along with a potential thread queue.  The
164   * other is the scheduler.  During a thread priority change, the user visible
165   * thread priority and the thread queue are first updated and the thread
166   * priority value here is changed.  Once this is done the scheduler is
167   * notified via the update priority operation, so that it can update its
168   * internal state and honour a new thread priority value.
169   */
170  struct {
171    /**
172     * @brief The thread priority value of this scheduler node.
173     *
174     * The producer of this value is _Thread_Change_priority().  The consumer
175     * is the scheduler via the unblock and update priority operations.
176     */
177    Priority_Control value;
178
179#if defined(RTEMS_SMP)
180    /**
181     * @brief Sequence lock to synchronize priority value updates.
182     */
183    SMP_sequence_lock_Control Lock;
184#endif
185
186    /**
187     * @brief In case a priority update is necessary and this is true, then
188     * enqueue the thread as the first of its priority group, otherwise enqueue
189     * the thread as the last of its priority group.
190     */
191    bool prepend_it;
192  } Priority;
193};
194
195#if defined(RTEMS_SMP)
196/**
197 * @brief The size of a scheduler node.
198 *
199 * This value is provided via <rtems/confdefs.h>.
200 */
201extern const size_t _Scheduler_Node_size;
202#endif
203
204#if defined(RTEMS_SMP)
205#define SCHEDULER_NODE_OF_THREAD_WAIT_NODE( node ) \
206  RTEMS_CONTAINER_OF( node, Scheduler_Node, Thread.Wait_node )
207
208#define SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ) \
209  RTEMS_CONTAINER_OF( node, Scheduler_Node, Thread.Scheduler_node.Chain )
210#endif
211
212#ifdef __cplusplus
213}
214#endif /* __cplusplus */
215
216#endif /* _RTEMS_SCORE_SCHEDULERNODE_H */
Note: See TracBrowser for help on using the repository browser.