1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSScoreSchedulerSMP |
---|
7 | * |
---|
8 | * @brief This header file provides interfaces of the |
---|
9 | * @ref RTEMSScoreSchedulerSMP which are used by the implementation and the |
---|
10 | * @ref RTEMSImplApplConfig. |
---|
11 | */ |
---|
12 | |
---|
13 | /* |
---|
14 | * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. |
---|
15 | * |
---|
16 | * embedded brains GmbH |
---|
17 | * Dornierstr. 4 |
---|
18 | * 82178 Puchheim |
---|
19 | * Germany |
---|
20 | * <rtems@embedded-brains.de> |
---|
21 | * |
---|
22 | * Redistribution and use in source and binary forms, with or without |
---|
23 | * modification, are permitted provided that the following conditions |
---|
24 | * are met: |
---|
25 | * 1. Redistributions of source code must retain the above copyright |
---|
26 | * notice, this list of conditions and the following disclaimer. |
---|
27 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
28 | * notice, this list of conditions and the following disclaimer in the |
---|
29 | * documentation and/or other materials provided with the distribution. |
---|
30 | * |
---|
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
32 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
33 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
34 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
35 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
36 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
37 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
38 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
39 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
41 | * POSSIBILITY OF SUCH DAMAGE. |
---|
42 | */ |
---|
43 | |
---|
44 | #ifndef _RTEMS_SCORE_SCHEDULERSMP_H |
---|
45 | #define _RTEMS_SCORE_SCHEDULERSMP_H |
---|
46 | |
---|
47 | #include <rtems/score/chain.h> |
---|
48 | #include <rtems/score/scheduler.h> |
---|
49 | |
---|
50 | #ifdef __cplusplus |
---|
51 | extern "C" { |
---|
52 | #endif /* __cplusplus */ |
---|
53 | |
---|
54 | /** |
---|
55 | * @defgroup RTEMSScoreSchedulerSMP SMP Scheduler |
---|
56 | * |
---|
57 | * @ingroup RTEMSScoreScheduler |
---|
58 | * |
---|
59 | * @brief This group contains the SMP Scheduler implementation. |
---|
60 | * |
---|
61 | * @{ |
---|
62 | */ |
---|
63 | |
---|
64 | /** |
---|
65 | * @brief Scheduler context specialization for SMP schedulers. |
---|
66 | */ |
---|
67 | typedef struct { |
---|
68 | /** |
---|
69 | * @brief Basic scheduler context. |
---|
70 | */ |
---|
71 | Scheduler_Context Base; |
---|
72 | |
---|
73 | /** |
---|
74 | * @brief The chain of scheduled nodes. |
---|
75 | */ |
---|
76 | Chain_Control Scheduled; |
---|
77 | } Scheduler_SMP_Context; |
---|
78 | |
---|
79 | /** |
---|
80 | * @brief SMP scheduler node states. |
---|
81 | */ |
---|
82 | typedef enum { |
---|
83 | /** |
---|
84 | * @brief This scheduler node is blocked. |
---|
85 | * |
---|
86 | * A scheduler node is blocked if the corresponding thread is not ready. |
---|
87 | */ |
---|
88 | SCHEDULER_SMP_NODE_BLOCKED, |
---|
89 | |
---|
90 | /** |
---|
91 | * @brief The scheduler node is scheduled. |
---|
92 | * |
---|
93 | * A scheduler node is scheduled if the corresponding thread is ready and the |
---|
94 | * scheduler allocated a processor for it. A scheduled node is assigned to |
---|
95 | * exactly one processor. The count of scheduled nodes in this scheduler |
---|
96 | * instance equals the processor count owned by the scheduler instance. |
---|
97 | */ |
---|
98 | SCHEDULER_SMP_NODE_SCHEDULED, |
---|
99 | |
---|
100 | /** |
---|
101 | * @brief This scheduler node is ready. |
---|
102 | * |
---|
103 | * A scheduler node is ready if the corresponding thread is ready and the |
---|
104 | * scheduler did not allocate a processor for it. |
---|
105 | */ |
---|
106 | SCHEDULER_SMP_NODE_READY |
---|
107 | } Scheduler_SMP_Node_state; |
---|
108 | |
---|
109 | /** |
---|
110 | * @brief Scheduler node specialization for SMP schedulers. |
---|
111 | */ |
---|
112 | typedef struct { |
---|
113 | /** |
---|
114 | * @brief Basic scheduler node. |
---|
115 | */ |
---|
116 | Scheduler_Node Base; |
---|
117 | |
---|
118 | /** |
---|
119 | * @brief The state of this node. |
---|
120 | */ |
---|
121 | Scheduler_SMP_Node_state state; |
---|
122 | |
---|
123 | /** |
---|
124 | * @brief The current priority of thread owning this node. |
---|
125 | */ |
---|
126 | Priority_Control priority; |
---|
127 | } Scheduler_SMP_Node; |
---|
128 | |
---|
129 | /** |
---|
130 | * @brief Starts an idle thread on the specified cpu. |
---|
131 | * |
---|
132 | * @param scheduler The scheduler instance. |
---|
133 | * @param[in, out] idle The idle thread to schedule. |
---|
134 | * @param[out] cpu The cpu to run the idle thread on. |
---|
135 | */ |
---|
136 | void _Scheduler_SMP_Start_idle( |
---|
137 | const Scheduler_Control *scheduler, |
---|
138 | Thread_Control *idle, |
---|
139 | struct Per_CPU_Control *cpu |
---|
140 | ); |
---|
141 | |
---|
142 | /** @} */ |
---|
143 | |
---|
144 | #ifdef __cplusplus |
---|
145 | } |
---|
146 | #endif /* __cplusplus */ |
---|
147 | |
---|
148 | #endif /* _RTEMS_SCORE_SCHEDULERSMP_H */ |
---|