![]() |
|
|||
File indexing completed on 2025-05-11 08:24:13
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSScoreSchedulerEDF 0007 * 0008 * @brief This header file provides interfaces of the 0009 * @ref RTEMSScoreSchedulerEDF which are used by the implementation and the 0010 * @ref RTEMSImplApplConfig. 0011 */ 0012 0013 /* 0014 * Copryight (c) 2011 Petr Benes. 0015 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). 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_SCHEDULEREDF_H 0040 #define _RTEMS_SCORE_SCHEDULEREDF_H 0041 0042 #include <rtems/score/priority.h> 0043 #include <rtems/score/scheduler.h> 0044 #include <rtems/score/schedulerpriority.h> 0045 #include <rtems/score/rbtree.h> 0046 0047 #include <limits.h> 0048 0049 #ifdef __cplusplus 0050 extern "C" { 0051 #endif 0052 0053 /** 0054 * @defgroup RTEMSScoreSchedulerEDF EDF Scheduler 0055 * 0056 * @ingroup RTEMSScoreScheduler 0057 * 0058 * @brief This group contains the EDF Scheduler implementation. 0059 * 0060 * @{ 0061 */ 0062 0063 /* 0064 * Actually the EDF scheduler supports a maximum priority of 0065 * 0x7fffffffffffffff, but the user API is limited to uint32_t or int for 0066 * thread priorities. Ignore ILP64 targets for now. 0067 */ 0068 #define SCHEDULER_EDF_MAXIMUM_PRIORITY INT_MAX 0069 0070 /** 0071 * Entry points for the Earliest Deadline First Scheduler. 0072 */ 0073 #define SCHEDULER_EDF_ENTRY_POINTS \ 0074 { \ 0075 _Scheduler_EDF_Initialize, /* initialize entry point */ \ 0076 _Scheduler_EDF_Schedule, /* schedule entry point */ \ 0077 _Scheduler_EDF_Yield, /* yield entry point */ \ 0078 _Scheduler_EDF_Block, /* block entry point */ \ 0079 _Scheduler_EDF_Unblock, /* unblock entry point */ \ 0080 _Scheduler_EDF_Update_priority, /* update priority entry point */ \ 0081 _Scheduler_EDF_Map_priority, /* map priority entry point */ \ 0082 _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \ 0083 SCHEDULER_DEFAULT_SMP_OPERATIONS \ 0084 _Scheduler_EDF_Node_initialize, /* node initialize entry point */ \ 0085 _Scheduler_default_Node_destroy, /* node destroy entry point */ \ 0086 _Scheduler_EDF_Release_job, /* new period of task */ \ 0087 _Scheduler_EDF_Cancel_job, /* cancel period of task */ \ 0088 _Scheduler_default_Start_idle /* start idle entry point */ \ 0089 SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \ 0090 } 0091 0092 typedef struct { 0093 /** 0094 * @brief Basic scheduler context. 0095 */ 0096 Scheduler_Context Base; 0097 0098 /** 0099 * Top of the ready queue. 0100 */ 0101 RBTree_Control Ready; 0102 } Scheduler_EDF_Context; 0103 0104 /** 0105 * @brief Scheduler node specialization for EDF schedulers. 0106 */ 0107 typedef struct { 0108 /** 0109 * @brief Basic scheduler node. 0110 */ 0111 Scheduler_Node Base; 0112 0113 /** 0114 * Rbtree node related to this thread. 0115 */ 0116 RBTree_Node Node; 0117 0118 /** 0119 * @brief The thread priority currently used for this scheduler instance. 0120 */ 0121 Priority_Control priority; 0122 } Scheduler_EDF_Node; 0123 0124 /** 0125 * @brief Initializes EDF scheduler. 0126 * 0127 * This routine initializes the EDF scheduler. 0128 * 0129 * @param[in, out] scheduler The scheduler instance. 0130 */ 0131 void _Scheduler_EDF_Initialize( const Scheduler_Control *scheduler ); 0132 0133 /** 0134 * @brief Removes the blocking thread from the ready queue and schedules is only 0135 * again if the thread is executing or the heir thread. 0136 * 0137 * @param[in, out] scheduler The scheduler for the operation. 0138 * @param the_thread The thread to operate upon. 0139 * @param[in, out] node The scheduler node for this thread. 0140 */ 0141 void _Scheduler_EDF_Block( 0142 const Scheduler_Control *scheduler, 0143 Thread_Control *the_thread, 0144 Scheduler_Node *node 0145 ); 0146 0147 /** 0148 * @brief Sets the heir thread to be the next ready thread 0149 * in the rbtree ready queue. 0150 * 0151 * This kernel routine sets the heir thread to be the next ready thread 0152 * in the rbtree ready queue. 0153 * 0154 * @param[in, out] scheduler The scheduler instance. 0155 * @param the_thread The thread being scheduled. 0156 */ 0157 void _Scheduler_EDF_Schedule( 0158 const Scheduler_Control *scheduler, 0159 Thread_Control *the_thread 0160 ); 0161 0162 /** 0163 * @brief Initializes an EDF specific scheduler node of @a the_thread. 0164 * 0165 * @param scheduler The scheduler instance. 0166 * @param node The node being initialized. 0167 * @param the_thread The thread of the node. 0168 * @param priority The thread priority. 0169 */ 0170 void _Scheduler_EDF_Node_initialize( 0171 const Scheduler_Control *scheduler, 0172 Scheduler_Node *node, 0173 Thread_Control *the_thread, 0174 Priority_Control priority 0175 ); 0176 0177 /** 0178 * @brief Performs an unblocking of the thread. 0179 * 0180 * @param[in, out] scheduler The scheduler instance. 0181 * @param the_thread The unblocking thread. May be set as new heir. 0182 * @param[in, out] node The scheduler node for the thread. 0183 */ 0184 void _Scheduler_EDF_Unblock( 0185 const Scheduler_Control *scheduler, 0186 Thread_Control *the_thread, 0187 Scheduler_Node *node 0188 ); 0189 0190 /** 0191 * @brief Updates the priority of the scheduler node. 0192 * 0193 * @param scheduler The scheduler instance. 0194 * @param the_thread The thread for the operation. 0195 * @param[in, out] node The priority node to update the priority of. 0196 */ 0197 void _Scheduler_EDF_Update_priority( 0198 const Scheduler_Control *scheduler, 0199 Thread_Control *the_thread, 0200 Scheduler_Node *node 0201 ); 0202 0203 /** 0204 * @brief Gets the mapped priority map of the priority control. 0205 * 0206 * @param scheduler Not used in this operation. 0207 * @param priority The priority control to get the priority map of. 0208 * 0209 * @return The mapped priority map of @a priority. 0210 */ 0211 Priority_Control _Scheduler_EDF_Map_priority( 0212 const Scheduler_Control *scheduler, 0213 Priority_Control priority 0214 ); 0215 0216 /** 0217 * @brief Gets the unmapped priority map of the priority control. 0218 * 0219 * @param scheduler Not used in this operation. 0220 * @param priority The priority control to get the priority map of. 0221 * 0222 * @return The unmapped priority map of @a priority. 0223 */ 0224 Priority_Control _Scheduler_EDF_Unmap_priority( 0225 const Scheduler_Control *scheduler, 0226 Priority_Control priority 0227 ); 0228 0229 /** 0230 * @brief Executes a thread yield for the thread. 0231 * 0232 * @param[in, out] scheduler The scheduler instance. 0233 * @param the_thread The thread that performs the yield. 0234 * @param[in, out] node The scheduler node for this thread. 0235 */ 0236 void _Scheduler_EDF_Yield( 0237 const Scheduler_Control *scheduler, 0238 Thread_Control *the_thread, 0239 Scheduler_Node *node 0240 ); 0241 0242 /** 0243 * @brief Releases a EDF job. 0244 * 0245 * @param scheduler The scheduler instance 0246 * @param the_thread The thread 0247 * @param[in, out] priority_node The priority node for the operation. 0248 * @param deadline The deadline for the job. 0249 * @param[in, out] queue_context The thread queue context. 0250 */ 0251 void _Scheduler_EDF_Release_job( 0252 const Scheduler_Control *scheduler, 0253 Thread_Control *the_thread, 0254 Priority_Node *priority_node, 0255 uint64_t deadline, 0256 Thread_queue_Context *queue_context 0257 ); 0258 0259 /** 0260 * @brief Cancels a job and removes the thread from the queue context. 0261 * 0262 * @param scheduler The scheduler instance. 0263 * @param the_thread The thread for the operation. 0264 * @param[in, out] priority_node The corresponding priority node. 0265 * @param[in, out] queue_context The thread queue context. 0266 */ 0267 void _Scheduler_EDF_Cancel_job( 0268 const Scheduler_Control *scheduler, 0269 Thread_Control *the_thread, 0270 Priority_Node *priority_node, 0271 Thread_queue_Context *queue_context 0272 ); 0273 0274 #ifdef __cplusplus 0275 } 0276 #endif 0277 0278 /** @} */ 0279 0280 #endif 0281 /* 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 |
![]() ![]() |