![]() |
|
|||
File indexing completed on 2025-05-11 08:24:12
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSImplClassicScheduler 0007 * 0008 * @brief This header file defines the main parts of the Scheduler Manager API. 0009 */ 0010 0011 /* 0012 * Copyright (C) 2013, 2021 embedded brains GmbH & Co. KG 0013 * Copyright (C) 1988, 2017 On-Line Applications Research Corporation (OAR) 0014 * 0015 * Redistribution and use in source and binary forms, with or without 0016 * modification, are permitted provided that the following conditions 0017 * are met: 0018 * 1. Redistributions of source code must retain the above copyright 0019 * notice, this list of conditions and the following disclaimer. 0020 * 2. Redistributions in binary form must reproduce the above copyright 0021 * notice, this list of conditions and the following disclaimer in the 0022 * documentation and/or other materials provided with the distribution. 0023 * 0024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0027 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0028 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0029 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0030 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0031 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0032 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0033 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0034 * POSSIBILITY OF SUCH DAMAGE. 0035 */ 0036 0037 /* 0038 * This file is part of the RTEMS quality process and was automatically 0039 * generated. If you find something that needs to be fixed or 0040 * worded better please post a report or patch to an RTEMS mailing list 0041 * or raise a bug report: 0042 * 0043 * https://www.rtems.org/bugs.html 0044 * 0045 * For information on updating and regenerating please refer to the How-To 0046 * section in the Software Requirements Engineering chapter of the 0047 * RTEMS Software Engineering manual. The manual is provided as a part of 0048 * a release. For development sources please refer to the online 0049 * documentation at: 0050 * 0051 * https://docs.rtems.org 0052 */ 0053 0054 /* Generated from spec:/rtems/scheduler/if/header */ 0055 0056 #ifndef _RTEMS_RTEMS_SCHEDULER_H 0057 #define _RTEMS_RTEMS_SCHEDULER_H 0058 0059 #include <stddef.h> 0060 #include <stdint.h> 0061 #include <sys/cpuset.h> 0062 #include <rtems/rtems/status.h> 0063 #include <rtems/rtems/types.h> 0064 #include <rtems/score/smp.h> 0065 0066 #ifdef __cplusplus 0067 extern "C" { 0068 #endif 0069 0070 /* Generated from spec:/rtems/scheduler/if/group */ 0071 0072 /** 0073 * @defgroup RTEMSAPIClassicScheduler Scheduler Manager 0074 * 0075 * @ingroup RTEMSAPIClassic 0076 * 0077 * @brief The scheduling concepts relate to the allocation of processing time 0078 * for tasks. 0079 * 0080 * The concept of scheduling in real-time systems dictates the ability to 0081 * provide an immediate response to specific external events, particularly the 0082 * necessity of scheduling tasks to run within a specified time limit after the 0083 * occurrence of an event. For example, software embedded in life-support 0084 * systems used to monitor hospital patients must take instant action if a 0085 * change in the patient’s status is detected. 0086 * 0087 * The component of RTEMS responsible for providing this capability is 0088 * appropriately called the scheduler. The scheduler’s sole purpose is to 0089 * allocate the all important resource of processor time to the various tasks 0090 * competing for attention. 0091 */ 0092 0093 /* Generated from spec:/rtems/scheduler/if/ident */ 0094 0095 /** 0096 * @ingroup RTEMSAPIClassicScheduler 0097 * 0098 * @brief Identifies a scheduler by the object name. 0099 * 0100 * @param name is the scheduler name to look up. 0101 * 0102 * @param[out] id is the pointer to an ::rtems_id object. When the directive 0103 * call is successful, the identifier of the scheduler will be stored in this 0104 * object. 0105 * 0106 * This directive obtains a scheduler identifier associated with the scheduler 0107 * name specified in ``name``. 0108 * 0109 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0110 * 0111 * @retval ::RTEMS_INVALID_NAME There was no scheduler associated with the 0112 * name. 0113 * 0114 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. 0115 * 0116 * @par Notes 0117 * @parblock 0118 * The scheduler name is determined by the scheduler configuration. 0119 * 0120 * The scheduler identifier is used with other scheduler related directives to 0121 * access the scheduler. 0122 * @endparblock 0123 * 0124 * @par Constraints 0125 * @parblock 0126 * The following constraints apply to this directive: 0127 * 0128 * * The directive may be called from within any runtime context. 0129 * 0130 * * The directive will not cause the calling task to be preempted. 0131 * @endparblock 0132 */ 0133 rtems_status_code rtems_scheduler_ident( rtems_name name, rtems_id *id ); 0134 0135 /* Generated from spec:/rtems/scheduler/if/ident-by-processor */ 0136 0137 /** 0138 * @ingroup RTEMSAPIClassicScheduler 0139 * 0140 * @brief Identifies a scheduler by the processor index. 0141 * 0142 * @param cpu_index is the processor index to identify the scheduler. 0143 * 0144 * @param[out] id is the pointer to an ::rtems_id object. When the directive 0145 * call is successful, the identifier of the scheduler will be stored in this 0146 * object. 0147 * 0148 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0149 * 0150 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. 0151 * 0152 * @retval ::RTEMS_INVALID_NAME The processor index was invalid. 0153 * 0154 * @retval ::RTEMS_INCORRECT_STATE The processor index was valid, however, the 0155 * corresponding processor was not owned by a scheduler. 0156 * 0157 * @par Constraints 0158 * @parblock 0159 * The following constraints apply to this directive: 0160 * 0161 * * The directive may be called from within any runtime context. 0162 * 0163 * * The directive will not cause the calling task to be preempted. 0164 * @endparblock 0165 */ 0166 rtems_status_code rtems_scheduler_ident_by_processor( 0167 uint32_t cpu_index, 0168 rtems_id *id 0169 ); 0170 0171 /* Generated from spec:/rtems/scheduler/if/ident-by-processor-set */ 0172 0173 /** 0174 * @ingroup RTEMSAPIClassicScheduler 0175 * 0176 * @brief Identifies a scheduler by the processor set. 0177 * 0178 * @param cpusetsize is the size of the processor set referenced by ``cpuset`` 0179 * in bytes. The size shall be positive. 0180 * 0181 * @param cpuset is the pointer to a cpu_set_t. The referenced processor set 0182 * will be used to identify the scheduler. 0183 * 0184 * @param[out] id is the pointer to an ::rtems_id object. When the directive 0185 * call is successful, the identifier of the scheduler will be stored in this 0186 * object. 0187 * 0188 * The scheduler is selected according to the highest numbered online processor 0189 * in the specified processor set. 0190 * 0191 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0192 * 0193 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. 0194 * 0195 * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. 0196 * 0197 * @retval ::RTEMS_INVALID_SIZE The processor set size was invalid. 0198 * 0199 * @retval ::RTEMS_INVALID_NAME The processor set contained no online 0200 * processor. 0201 * 0202 * @retval ::RTEMS_INCORRECT_STATE The processor set was valid, however, the 0203 * highest numbered online processor in the processor set was not owned by a 0204 * scheduler. 0205 * 0206 * @par Constraints 0207 * @parblock 0208 * The following constraints apply to this directive: 0209 * 0210 * * The directive may be called from within any runtime context. 0211 * 0212 * * The directive will not cause the calling task to be preempted. 0213 * @endparblock 0214 */ 0215 rtems_status_code rtems_scheduler_ident_by_processor_set( 0216 size_t cpusetsize, 0217 const cpu_set_t *cpuset, 0218 rtems_id *id 0219 ); 0220 0221 /* Generated from spec:/rtems/scheduler/if/get-maximum-priority */ 0222 0223 /** 0224 * @ingroup RTEMSAPIClassicScheduler 0225 * 0226 * @brief Gets the maximum task priority of the scheduler. 0227 * 0228 * @param scheduler_id is the scheduler identifier. 0229 * 0230 * @param[out] priority is the pointer to an ::rtems_task_priority object. 0231 * When the directive the maximum priority of the scheduler will be stored in 0232 * this object. 0233 * 0234 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0235 * 0236 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the 0237 * identifier specified by ``scheduler_id``. 0238 * 0239 * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. 0240 * 0241 * @par Constraints 0242 * @parblock 0243 * The following constraints apply to this directive: 0244 * 0245 * * The directive may be called from within any runtime context. 0246 * 0247 * * The directive will not cause the calling task to be preempted. 0248 * @endparblock 0249 */ 0250 rtems_status_code rtems_scheduler_get_maximum_priority( 0251 rtems_id scheduler_id, 0252 rtems_task_priority *priority 0253 ); 0254 0255 /* Generated from spec:/rtems/scheduler/if/map-priority-to-posix */ 0256 0257 /** 0258 * @ingroup RTEMSAPIClassicScheduler 0259 * 0260 * @brief Maps a Classic API task priority to the corresponding POSIX thread 0261 * priority. 0262 * 0263 * @param scheduler_id is the scheduler identifier. 0264 * 0265 * @param priority is the Classic API task priority to map. 0266 * 0267 * @param[out] posix_priority is the pointer to an ``int`` object. When the 0268 * directive call is successful, the POSIX thread priority value 0269 * corresponding to the specified Classic API task priority value will be 0270 * stored in this object. 0271 * 0272 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0273 * 0274 * @retval ::RTEMS_INVALID_ADDRESS The ``posix_priority`` parameter was NULL. 0275 * 0276 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the 0277 * identifier specified by ``scheduler_id``. 0278 * 0279 * @retval ::RTEMS_INVALID_PRIORITY The Classic API task priority was invalid. 0280 * 0281 * @par Constraints 0282 * @parblock 0283 * The following constraints apply to this directive: 0284 * 0285 * * The directive may be called from within any runtime context. 0286 * 0287 * * The directive will not cause the calling task to be preempted. 0288 * @endparblock 0289 */ 0290 rtems_status_code rtems_scheduler_map_priority_to_posix( 0291 rtems_id scheduler_id, 0292 rtems_task_priority priority, 0293 int *posix_priority 0294 ); 0295 0296 /* Generated from spec:/rtems/scheduler/if/map-priority-from-posix */ 0297 0298 /** 0299 * @ingroup RTEMSAPIClassicScheduler 0300 * 0301 * @brief Maps a POSIX thread priority to the corresponding Classic API task 0302 * priority. 0303 * 0304 * @param scheduler_id is the scheduler identifier. 0305 * 0306 * @param posix_priority is the POSIX thread priority to map. 0307 * 0308 * @param[out] priority is the pointer to an ::rtems_task_priority object. 0309 * When the directive call is successful, the Classic API task priority value 0310 * corresponding to the specified POSIX thread priority value will be stored 0311 * in this object. 0312 * 0313 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0314 * 0315 * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. 0316 * 0317 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the 0318 * identifier specified by ``scheduler_id``. 0319 * 0320 * @retval ::RTEMS_INVALID_PRIORITY The POSIX thread priority was invalid. 0321 * 0322 * @par Constraints 0323 * @parblock 0324 * The following constraints apply to this directive: 0325 * 0326 * * The directive may be called from within any runtime context. 0327 * 0328 * * The directive will not cause the calling task to be preempted. 0329 * @endparblock 0330 */ 0331 rtems_status_code rtems_scheduler_map_priority_from_posix( 0332 rtems_id scheduler_id, 0333 int posix_priority, 0334 rtems_task_priority *priority 0335 ); 0336 0337 /* Generated from spec:/rtems/scheduler/if/get-processor */ 0338 0339 /** 0340 * @ingroup RTEMSAPIClassicScheduler 0341 * 0342 * @brief Returns the index of the current processor. 0343 * 0344 * Where the system was built with SMP support disabled, this directive 0345 * evaluates to a compile time constant of zero. 0346 * 0347 * Where the system was built with SMP support enabled, this directive returns 0348 * the index of the current processor. The set of processor indices is the 0349 * range of integers starting with zero up to 0350 * rtems_scheduler_get_processor_maximum() minus one. 0351 * 0352 * @return Returns the index of the current processor. 0353 * 0354 * @par Notes 0355 * Outside of sections with disabled thread dispatching the current processor 0356 * index may change after every instruction since the thread may migrate from 0357 * one processor to another. Sections with disabled interrupts are sections 0358 * with thread dispatching disabled. 0359 * 0360 * @par Constraints 0361 * @parblock 0362 * The following constraints apply to this directive: 0363 * 0364 * * The directive may be called from within any runtime context. 0365 * 0366 * * The directive will not cause the calling task to be preempted. 0367 * @endparblock 0368 */ 0369 uint32_t rtems_scheduler_get_processor( void ); 0370 0371 /* Generated from spec:/rtems/scheduler/if/get-processor-macro */ 0372 #define rtems_scheduler_get_processor() _SMP_Get_current_processor() 0373 0374 /* Generated from spec:/rtems/scheduler/if/get-processor-maximum */ 0375 0376 /** 0377 * @ingroup RTEMSAPIClassicScheduler 0378 * 0379 * @brief Returns the processor maximum supported by the system. 0380 * 0381 * Where the system was built with SMP support disabled, this directive 0382 * evaluates to a compile time constant of one. 0383 * 0384 * Where the system was built with SMP support enabled, this directive returns 0385 * the minimum of the processors (physically or virtually) available at the 0386 * target and the configured processor maximum (see @ref 0387 * CONFIGURE_MAXIMUM_PROCESSORS). Not all processors in the range from 0388 * processor index zero to the last processor index (which is the processor 0389 * maximum minus one) may be configured to be used by a scheduler or may be 0390 * online (online processors have a scheduler assigned). 0391 * 0392 * @return Returns the processor maximum supported by the system. 0393 * 0394 * @par Constraints 0395 * @parblock 0396 * The following constraints apply to this directive: 0397 * 0398 * * The directive may be called from within any runtime context. 0399 * 0400 * * The directive will not cause the calling task to be preempted. 0401 * @endparblock 0402 */ 0403 uint32_t rtems_scheduler_get_processor_maximum( void ); 0404 0405 /* Generated from spec:/rtems/scheduler/if/get-processor-maximum-macro */ 0406 #define rtems_scheduler_get_processor_maximum() _SMP_Get_processor_maximum() 0407 0408 /* Generated from spec:/rtems/scheduler/if/get-processor-set */ 0409 0410 /** 0411 * @ingroup RTEMSAPIClassicScheduler 0412 * 0413 * @brief Gets the set of processors owned by the scheduler. 0414 * 0415 * @param scheduler_id is the scheduler identifier. 0416 * 0417 * @param cpusetsize is the size of the processor set referenced by ``cpuset`` 0418 * in bytes. 0419 * 0420 * @param[out] cpuset is the pointer to a cpu_set_t object. When the directive 0421 * call is successful, the processor set of the scheduler will be stored in 0422 * this object. A set bit in the processor set means that the corresponding 0423 * processor is owned by the scheduler, otherwise the bit is cleared. 0424 * 0425 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0426 * 0427 * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. 0428 * 0429 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the 0430 * identifier specified by ``scheduler_id``. 0431 * 0432 * @retval ::RTEMS_INVALID_SIZE The provided processor set was too small for 0433 * the set of processors owned by the scheduler. 0434 * 0435 * @par Constraints 0436 * @parblock 0437 * The following constraints apply to this directive: 0438 * 0439 * * The directive may be called from within any runtime context. 0440 * 0441 * * The directive will not cause the calling task to be preempted. 0442 * @endparblock 0443 */ 0444 rtems_status_code rtems_scheduler_get_processor_set( 0445 rtems_id scheduler_id, 0446 size_t cpusetsize, 0447 cpu_set_t *cpuset 0448 ); 0449 0450 /* Generated from spec:/rtems/scheduler/if/add-processor */ 0451 0452 /** 0453 * @ingroup RTEMSAPIClassicScheduler 0454 * 0455 * @brief Adds the processor to the set of processors owned by the scheduler. 0456 * 0457 * @param scheduler_id is the scheduler identifier. 0458 * 0459 * @param cpu_index is the index of the processor to add. 0460 * 0461 * This directive adds the processor specified by the ``cpu_index`` to the 0462 * scheduler specified by ``scheduler_id``. 0463 * 0464 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0465 * 0466 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the 0467 * identifier specified by ``scheduler_id``. 0468 * 0469 * @retval ::RTEMS_NOT_CONFIGURED The processor was not configured to be used 0470 * by the application. 0471 * 0472 * @retval ::RTEMS_INCORRECT_STATE The processor was configured to be used by 0473 * the application, however, it was not online. 0474 * 0475 * @retval ::RTEMS_RESOURCE_IN_USE The processor was already assigned to a 0476 * scheduler. 0477 * 0478 * @par Constraints 0479 * @parblock 0480 * The following constraints apply to this directive: 0481 * 0482 * * The directive may be called from within device driver initialization 0483 * context. 0484 * 0485 * * The directive may be called from within task context. 0486 * 0487 * * The directive may obtain and release the object allocator mutex. This may 0488 * cause the calling task to be preempted. 0489 * @endparblock 0490 */ 0491 rtems_status_code rtems_scheduler_add_processor( 0492 rtems_id scheduler_id, 0493 uint32_t cpu_index 0494 ); 0495 0496 /* Generated from spec:/rtems/scheduler/if/remove-processor */ 0497 0498 /** 0499 * @ingroup RTEMSAPIClassicScheduler 0500 * 0501 * @brief Removes the processor from the set of processors owned by the 0502 * scheduler. 0503 * 0504 * @param scheduler_id is the scheduler identifier. 0505 * 0506 * @param cpu_index is the index of the processor to remove. 0507 * 0508 * This directive removes the processor specified by the ``cpu_index`` from the 0509 * scheduler specified by ``scheduler_id``. 0510 * 0511 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. 0512 * 0513 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the 0514 * identifier specified by ``scheduler_id``. 0515 * 0516 * @retval ::RTEMS_INVALID_NUMBER The processor was not owned by the scheduler. 0517 * 0518 * @retval ::RTEMS_RESOURCE_IN_USE The processor was required by at least one 0519 * non-idle task that used the scheduler as its home scheduler. 0520 * 0521 * @retval ::RTEMS_RESOURCE_IN_USE The processor was the last processor owned 0522 * by the scheduler and there was at least one task that used the scheduler 0523 * as a helping scheduler. 0524 * 0525 * @par Notes 0526 * Removing a processor from a scheduler is a complex operation that involves 0527 * all tasks of the system. 0528 * 0529 * @par Constraints 0530 * @parblock 0531 * The following constraints apply to this directive: 0532 * 0533 * * The directive may be called from within device driver initialization 0534 * context. 0535 * 0536 * * The directive may be called from within task context. 0537 * 0538 * * The directive may obtain and release the object allocator mutex. This may 0539 * cause the calling task to be preempted. 0540 * @endparblock 0541 */ 0542 rtems_status_code rtems_scheduler_remove_processor( 0543 rtems_id scheduler_id, 0544 uint32_t cpu_index 0545 ); 0546 0547 #ifdef __cplusplus 0548 } 0549 #endif 0550 0551 #endif /* _RTEMS_RTEMS_SCHEDULER_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |