Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:13

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSScoreSchedulerSMP
0007  *
0008  * @brief This header file provides interfaces of the
0009  *   @ref RTEMSScoreSchedulerSMP which are used by the implementation and the
0010  *   @ref RTEMSImplApplConfig.
0011  */
0012 
0013 /*
0014  * Copyright (C) 2013, 2014 embedded brains GmbH & Co. KG
0015  *
0016  * Redistribution and use in source and binary forms, with or without
0017  * modification, are permitted provided that the following conditions
0018  * are met:
0019  * 1. Redistributions of source code must retain the above copyright
0020  *    notice, this list of conditions and the following disclaimer.
0021  * 2. Redistributions in binary form must reproduce the above copyright
0022  *    notice, this list of conditions and the following disclaimer in the
0023  *    documentation and/or other materials provided with the distribution.
0024  *
0025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0030  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0033  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0034  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0035  * POSSIBILITY OF SUCH DAMAGE.
0036  */
0037 
0038 #ifndef _RTEMS_SCORE_SCHEDULERSMP_H
0039 #define _RTEMS_SCORE_SCHEDULERSMP_H
0040 
0041 #include <rtems/score/chain.h>
0042 #include <rtems/score/scheduler.h>
0043 
0044 #ifdef __cplusplus
0045 extern "C" {
0046 #endif /* __cplusplus */
0047 
0048 /**
0049  * @defgroup RTEMSScoreSchedulerSMP SMP Scheduler
0050  *
0051  * @ingroup RTEMSScoreScheduler
0052  *
0053  * @brief This group contains the SMP Scheduler implementation.
0054  *
0055  * @{
0056  */
0057 
0058 /**
0059  * @brief Scheduler context specialization for SMP schedulers.
0060  */
0061 typedef struct {
0062   /**
0063    * @brief Basic scheduler context.
0064    */
0065   Scheduler_Context Base;
0066 
0067   /**
0068    * @brief The chain of scheduled nodes.
0069    */
0070   Chain_Control Scheduled;
0071 } Scheduler_SMP_Context;
0072 
0073 /**
0074  * @brief SMP scheduler node states.
0075  */
0076 typedef enum {
0077   /**
0078    * @brief This scheduler node is blocked.
0079    *
0080    * A scheduler node is blocked if the corresponding thread is not ready.
0081    */
0082   SCHEDULER_SMP_NODE_BLOCKED,
0083 
0084   /**
0085    * @brief The scheduler node is scheduled.
0086    *
0087    * A scheduler node is scheduled if the corresponding thread is ready and the
0088    * scheduler allocated a processor for it.  A scheduled node is assigned to
0089    * exactly one processor.  The count of scheduled nodes in this scheduler
0090    * instance equals the processor count owned by the scheduler instance.
0091    */
0092   SCHEDULER_SMP_NODE_SCHEDULED,
0093 
0094   /**
0095    * @brief This scheduler node is ready.
0096    *
0097    * A scheduler node is ready if the corresponding thread is ready and the
0098    * scheduler did not allocate a processor for it.
0099    */
0100   SCHEDULER_SMP_NODE_READY
0101 } Scheduler_SMP_Node_state;
0102 
0103 /**
0104  * @brief Scheduler node specialization for SMP schedulers.
0105  */
0106 typedef struct {
0107   /**
0108    * @brief Basic scheduler node.
0109    */
0110   Scheduler_Node Base;
0111 
0112   /**
0113    * @brief The state of this node.
0114    */
0115   Scheduler_SMP_Node_state state;
0116 
0117   /**
0118    * @brief The current priority of thread owning this node.
0119    */
0120   Priority_Control priority;
0121 } Scheduler_SMP_Node;
0122 
0123 /**
0124  * @brief Starts an idle thread on the specified cpu.
0125  *
0126  * @param scheduler The scheduler instance.
0127  * @param[in, out] idle The idle thread to schedule.
0128  * @param[out] cpu The cpu to run the idle thread on.
0129  */
0130 void _Scheduler_SMP_Start_idle(
0131   const Scheduler_Control *scheduler,
0132   Thread_Control          *idle,
0133   struct Per_CPU_Control  *cpu
0134 );
0135 
0136 /** @} */
0137 
0138 #ifdef __cplusplus
0139 }
0140 #endif /* __cplusplus */
0141 
0142 #endif /* _RTEMS_SCORE_SCHEDULERSMP_H */