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 RTEMSScoreSchedulerSimple
0007  *
0008  * @brief This header file provides interfaces of the
0009  *   @ref RTEMSScoreSchedulerSimple which are used by the implementation and
0010  *   the @ref RTEMSImplApplConfig.
0011  */
0012 
0013 /*
0014  *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
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_SCHEDULERSIMPLE_H
0039 #define _RTEMS_SCORE_SCHEDULERSIMPLE_H
0040 
0041 #include <rtems/score/scheduler.h>
0042 #include <rtems/score/schedulerpriority.h>
0043 
0044 #ifdef __cplusplus
0045 extern "C" {
0046 #endif
0047 
0048 /**
0049  * @defgroup RTEMSScoreSchedulerSimple Simple Priority Scheduler
0050  *
0051  * @ingroup RTEMSScoreScheduler
0052  *
0053  * @brief This group contains the Simple Priority Scheduler implementation.
0054  *
0055  * @{
0056  */
0057 
0058 #define SCHEDULER_SIMPLE_MAXIMUM_PRIORITY 255
0059 
0060 /**
0061  *  Entry points for Scheduler Simple
0062  */
0063 #define SCHEDULER_SIMPLE_ENTRY_POINTS \
0064   { \
0065     _Scheduler_simple_Initialize,         /* initialize entry point */ \
0066     _Scheduler_simple_Schedule,           /* schedule entry point */ \
0067     _Scheduler_simple_Yield,              /* yield entry point */ \
0068     _Scheduler_simple_Block,              /* block entry point */ \
0069     _Scheduler_simple_Unblock,            /* unblock entry point */ \
0070     _Scheduler_simple_Update_priority,    /* update priority entry point */ \
0071     _Scheduler_default_Map_priority,      /* map priority entry point */ \
0072     _Scheduler_default_Unmap_priority,    /* unmap priority entry point */ \
0073     SCHEDULER_DEFAULT_SMP_OPERATIONS \
0074     _Scheduler_default_Node_initialize,   /* node initialize entry point */ \
0075     _Scheduler_default_Node_destroy,      /* node destroy entry point */ \
0076     _Scheduler_default_Release_job,       /* new period of task */ \
0077     _Scheduler_default_Cancel_job,        /* cancel period of task */ \
0078     _Scheduler_default_Start_idle         /* start idle entry point */ \
0079     SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \
0080   }
0081 
0082 /**
0083  * @brief Simple scheduler context.
0084  */
0085 typedef struct {
0086   /**
0087    * @brief Basic scheduler context.
0088    */
0089   Scheduler_Context Base;
0090 
0091   /**
0092    * @brief One ready queue for all ready threads.
0093    */
0094   Chain_Control Ready;
0095 } Scheduler_simple_Context;
0096 
0097 /**
0098  * @brief Initializes simple scheduler.
0099  *
0100  * This routine initializes the simple scheduler.
0101  *
0102  * @param scheduler The scheduler to be initialized.
0103  */
0104 void _Scheduler_simple_Initialize( const Scheduler_Control *scheduler );
0105 
0106 /**
0107  * @brief Schedules threads.
0108  *
0109  * This routine sets the heir thread to be the next ready thread
0110  * on the ready queue by getting the first node in the scheduler
0111  * information.
0112  *
0113  * @param scheduler The scheduler instance.
0114  * @param the_thread causing the scheduling operation.
0115  */
0116 void _Scheduler_simple_Schedule(
0117   const Scheduler_Control *scheduler,
0118   Thread_Control          *the_thread
0119 );
0120 
0121 /**
0122  * @brief Performs the yield of a thread.
0123  *
0124  * @param scheduler The scheduler instance.
0125  * @param[in, out] the_thread The thread that performed the yield operation.
0126  * @param node The scheduler node of @a the_thread.
0127  */
0128 void _Scheduler_simple_Yield(
0129   const Scheduler_Control *scheduler,
0130   Thread_Control          *the_thread,
0131   Scheduler_Node          *node
0132 );
0133 
0134 /**
0135  * @brief Blocks the thread.
0136  *
0137  * @param scheduler The scheduler instance.
0138  * @param[in, out] the_thread The thread to block.
0139  * @param[in, out] node The @a thread's scheduler node.
0140  */
0141 void _Scheduler_simple_Block(
0142   const Scheduler_Control *scheduler,
0143   Thread_Control          *the_thread,
0144   Scheduler_Node          *node
0145 );
0146 
0147 /**
0148  * @brief Unblocks the thread.
0149  *
0150  * @param scheduler The scheduler instance.
0151  * @param[in, out] the_thread The thread to unblock.
0152  * @param[in, out] node The @a thread's scheduler node.
0153  */
0154 void _Scheduler_simple_Unblock(
0155   const Scheduler_Control *scheduler,
0156   Thread_Control          *the_thread,
0157   Scheduler_Node          *node
0158 );
0159 
0160 /**
0161  * @brief Updates the priority of the node.
0162  *
0163  * @param scheduler The scheduler instance.
0164  * @param the_thread The thread for the operation.
0165  * @param node The thread's scheduler node.
0166  */
0167 void _Scheduler_simple_Update_priority(
0168   const Scheduler_Control *scheduler,
0169   Thread_Control          *the_thread,
0170   Scheduler_Node          *node
0171 );
0172 
0173 /** @} */
0174 
0175 #ifdef __cplusplus
0176 }
0177 #endif
0178 
0179 #endif
0180 /* end of include file */