![]() |
|
|||
File indexing completed on 2025-05-11 08:24:13
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSScoreSchedulerSMPSimple 0007 * 0008 * @brief This header file provides the interfaces of the 0009 * @ref RTEMSScoreSchedulerSMPSimple. 0010 */ 0011 0012 /* 0013 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). 0014 * 0015 * Copyright (C) 2013, 2018 embedded brains GmbH & Co. KG 0016 * 0017 * Redistribution and use in source and binary forms, with or without 0018 * modification, are permitted provided that the following conditions 0019 * are met: 0020 * 1. Redistributions of source code must retain the above copyright 0021 * notice, this list of conditions and the following disclaimer. 0022 * 2. Redistributions in binary form must reproduce the above copyright 0023 * notice, this list of conditions and the following disclaimer in the 0024 * documentation and/or other materials provided with the distribution. 0025 * 0026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0036 * POSSIBILITY OF SUCH DAMAGE. 0037 */ 0038 0039 #ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H 0040 #define _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H 0041 0042 #ifdef __cplusplus 0043 extern "C" { 0044 #endif 0045 0046 #include <rtems/score/scheduler.h> 0047 #include <rtems/score/schedulerpriority.h> 0048 #include <rtems/score/schedulersmp.h> 0049 0050 /** 0051 * @defgroup RTEMSScoreSchedulerSMPSimple Simple Priority SMP Scheduler 0052 * 0053 * @ingroup RTEMSScoreSchedulerSMP 0054 * 0055 * @brief This group contains the Simple Priority SMP Scheduler implementation. 0056 * 0057 * The Simple Priority SMP Scheduler allocates a processor for the processor 0058 * count highest priority ready threads. The thread priority and position in 0059 * the ready chain are the only information to determine the scheduling 0060 * decision. Threads with an allocated processor are in the scheduled chain. 0061 * After initialization the scheduled chain has exactly processor count nodes. 0062 * Each processor has exactly one allocated thread after initialization. All 0063 * enqueue and extract operations may exchange threads with the scheduled 0064 * chain. One thread will be added and another will be removed. The scheduled 0065 * and ready chain is ordered according to the thread priority order. The 0066 * chain insert operations are O(count of ready threads), thus this scheduler 0067 * is unsuitable for most real-time applications. 0068 * 0069 * The thread preempt mode will be ignored. 0070 * 0071 * @{ 0072 */ 0073 0074 typedef struct { 0075 Scheduler_SMP_Context Base; 0076 Chain_Control Ready; 0077 } Scheduler_simple_SMP_Context; 0078 0079 #define SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY 255 0080 0081 /** 0082 * @brief Entry points for the Simple SMP Scheduler. 0083 */ 0084 #define SCHEDULER_SIMPLE_SMP_ENTRY_POINTS \ 0085 { \ 0086 _Scheduler_simple_SMP_Initialize, \ 0087 _Scheduler_default_Schedule, \ 0088 _Scheduler_simple_SMP_Yield, \ 0089 _Scheduler_simple_SMP_Block, \ 0090 _Scheduler_simple_SMP_Unblock, \ 0091 _Scheduler_simple_SMP_Update_priority, \ 0092 _Scheduler_default_Map_priority, \ 0093 _Scheduler_default_Unmap_priority, \ 0094 _Scheduler_simple_SMP_Ask_for_help, \ 0095 _Scheduler_simple_SMP_Reconsider_help_request, \ 0096 _Scheduler_simple_SMP_Withdraw_node, \ 0097 _Scheduler_simple_SMP_Make_sticky, \ 0098 _Scheduler_simple_SMP_Clean_sticky, \ 0099 _Scheduler_default_Pin_or_unpin_not_supported, \ 0100 _Scheduler_default_Pin_or_unpin_not_supported, \ 0101 _Scheduler_simple_SMP_Add_processor, \ 0102 _Scheduler_simple_SMP_Remove_processor, \ 0103 _Scheduler_simple_SMP_Node_initialize, \ 0104 _Scheduler_default_Node_destroy, \ 0105 _Scheduler_default_Release_job, \ 0106 _Scheduler_default_Cancel_job, \ 0107 _Scheduler_SMP_Start_idle \ 0108 SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \ 0109 } 0110 0111 /** 0112 * @brief Initializes the scheduler's context. 0113 * 0114 * @param scheduler The scheduler instance to initialize the context of. 0115 */ 0116 void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler ); 0117 0118 /** 0119 * @brief Initializes the node with the given attributes. 0120 * 0121 * @param scheduler The scheduler instance. 0122 * @param[out] node The node to initialize. 0123 * @param the_thread The user of the node, if RTEMS_SMP is defined. 0124 * @param priority The priority of the node to initialize. 0125 */ 0126 void _Scheduler_simple_SMP_Node_initialize( 0127 const Scheduler_Control *scheduler, 0128 Scheduler_Node *node, 0129 Thread_Control *the_thread, 0130 Priority_Control priority 0131 ); 0132 0133 /** 0134 * @brief Blocks a thread. 0135 * 0136 * @param scheduler The scheduler instance. 0137 * @param[in, out] thread The thread to block. 0138 * @param[in, out] node The scheduler node of @a thread. 0139 */ 0140 void _Scheduler_simple_SMP_Block( 0141 const Scheduler_Control *scheduler, 0142 Thread_Control *thread, 0143 Scheduler_Node *node 0144 ); 0145 0146 /** 0147 * @brief Unblocks a thread. 0148 * 0149 * @param scheduler The scheduler instance. 0150 * @param[in, out] thread The thread to unblock. 0151 * @param[in, out] node The scheduler node of @a thread. 0152 */ 0153 void _Scheduler_simple_SMP_Unblock( 0154 const Scheduler_Control *scheduler, 0155 Thread_Control *thread, 0156 Scheduler_Node *node 0157 ); 0158 0159 /** 0160 * @brief Updates the priority of the node. 0161 * 0162 * @param scheduler The scheduler instance. 0163 * @param the_thread The thread of @a node. 0164 * @param node The node to update the priority of. 0165 */ 0166 void _Scheduler_simple_SMP_Update_priority( 0167 const Scheduler_Control *scheduler, 0168 Thread_Control *the_thread, 0169 Scheduler_Node *node 0170 ); 0171 0172 /** 0173 * @brief Asks for help. 0174 * 0175 * @param scheduler The scheduler instance to ask for help. 0176 * @param the_thread The thread needing help. 0177 * @param node The scheduler node. 0178 * 0179 * @retval true Ask for help was successful. 0180 * @retval false Ask for help was not successful. 0181 */ 0182 bool _Scheduler_simple_SMP_Ask_for_help( 0183 const Scheduler_Control *scheduler, 0184 Thread_Control *the_thread, 0185 Scheduler_Node *node 0186 ); 0187 0188 /** 0189 * @brief Reconsiders help. 0190 * 0191 * @param scheduler The scheduler instance to reconsider the help 0192 * request. 0193 * @param the_thread The thread reconsidering a help request. 0194 * @param node The scheduler node. 0195 */ 0196 void _Scheduler_simple_SMP_Reconsider_help_request( 0197 const Scheduler_Control *scheduler, 0198 Thread_Control *the_thread, 0199 Scheduler_Node *node 0200 ); 0201 0202 /** 0203 * @brief Withdraws node. 0204 * 0205 * @param scheduler The scheduler instance to withdraw the node. 0206 * @param the_thread The thread using the node. 0207 * @param node The scheduler node to withdraw. 0208 * @param next_state The next thread scheduler state in the case the node is 0209 * scheduled. 0210 */ 0211 void _Scheduler_simple_SMP_Withdraw_node( 0212 const Scheduler_Control *scheduler, 0213 Thread_Control *the_thread, 0214 Scheduler_Node *node, 0215 Thread_Scheduler_state next_state 0216 ); 0217 0218 /** 0219 * @brief Makes the node sticky. 0220 * 0221 * @param scheduler is the scheduler of the node. 0222 * 0223 * @param[in, out] the_thread is the thread owning the node. 0224 * 0225 * @param[in, out] node is the scheduler node to make sticky. 0226 */ 0227 void _Scheduler_simple_SMP_Make_sticky( 0228 const Scheduler_Control *scheduler, 0229 Thread_Control *the_thread, 0230 Scheduler_Node *node 0231 ); 0232 0233 /** 0234 * @brief Cleans the sticky property from the node. 0235 * 0236 * @param scheduler is the scheduler of the node. 0237 * 0238 * @param[in, out] the_thread is the thread owning the node. 0239 * 0240 * @param[in, out] node is the scheduler node to clean the sticky property. 0241 */ 0242 void _Scheduler_simple_SMP_Clean_sticky( 0243 const Scheduler_Control *scheduler, 0244 Thread_Control *the_thread, 0245 Scheduler_Node *node 0246 ); 0247 0248 /** 0249 * @brief Adds @a idle to @a scheduler. 0250 * 0251 * @param[in, out] scheduler The scheduler instance to add the processor to. 0252 * @param idle The idle thread control. 0253 */ 0254 void _Scheduler_simple_SMP_Add_processor( 0255 const Scheduler_Control *scheduler, 0256 Thread_Control *idle 0257 ); 0258 0259 /** 0260 * @brief Removes an idle thread from the given cpu. 0261 * 0262 * @param scheduler The scheduler instance. 0263 * @param cpu The cpu control to remove from @a scheduler. 0264 * 0265 * @return The idle thread of the processor. 0266 */ 0267 Thread_Control *_Scheduler_simple_SMP_Remove_processor( 0268 const Scheduler_Control *scheduler, 0269 struct Per_CPU_Control *cpu 0270 ); 0271 0272 /** 0273 * Performs a yield operation for the thread. 0274 * 0275 * @param scheduler The scheduler instance. 0276 * @param thread The thread to yield. 0277 * @param[in, out] node The node of the thread to perform a yield. 0278 */ 0279 void _Scheduler_simple_SMP_Yield( 0280 const Scheduler_Control *scheduler, 0281 Thread_Control *thread, 0282 Scheduler_Node *node 0283 ); 0284 0285 /** @} */ 0286 0287 #ifdef __cplusplus 0288 } 0289 #endif 0290 0291 #endif 0292 /* end of include file */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |