source: rtems/cpukit/include/rtems/score/schedulersimpleimpl.h @ 7b85efb8

Last change on this file since 7b85efb8 was 7b85efb8, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 21:16:11

cpukit/include/rtems/score/[s-z]*.h: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSScoreSchedulerSimple
7 *
8 * @brief This header file provides interfaces of the
9 *   @ref RTEMSScoreSchedulerSimple which are only used by the implementation.
10 */
11
12/*
13 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 *    notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 *    notice, this list of conditions and the following disclaimer in the
22 *    documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H
38#define _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H
39
40#include <rtems/score/schedulersimple.h>
41#include <rtems/score/chainimpl.h>
42#include <rtems/score/schedulerimpl.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/**
49 * @addtogroup RTEMSScoreSchedulerSimple
50 *
51 * @{
52 */
53
54/**
55 * @brief Gets context of the scheduler.
56 *
57 * @param scheduler The scheduler instance to get the context of.
58 *
59 * @return The context of @a scheduler.
60 */
61RTEMS_INLINE_ROUTINE Scheduler_simple_Context *
62  _Scheduler_simple_Get_context( const Scheduler_Control *scheduler )
63{
64  return (Scheduler_simple_Context *) _Scheduler_Get_context( scheduler );
65}
66
67/**
68 * @brief Checks if the priority is less or equal than the priority of the node.
69 *
70 * @param key is the priority to compare.
71 *
72 * @param to_insert is the chain node to insert.
73 *
74 * @param next is the chain node to compare the priority of.
75 *
76 * @retval true @a to_insert is smaller or equal than the priority of @a next.
77 * @retval false @a to_insert is greater than the priority of @a next.
78 */
79RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Priority_less_equal(
80  const void       *key,
81  const Chain_Node *to_insert,
82  const Chain_Node *next
83)
84{
85  const unsigned int   *priority_to_insert;
86  const Thread_Control *thread_next;
87
88  (void) to_insert;
89  priority_to_insert = (const unsigned int *) key;
90  thread_next = (const Thread_Control *) next;
91
92  return *priority_to_insert <= _Thread_Get_priority( thread_next );
93}
94
95/**
96 * @brief Inserts the thread control with the given priority into the chain.
97 *
98 * @param[in, out] chain The chain to insert @a to_insert in.
99 * @param[in, out] to_insert The node to insert into @a chain.
100 * @param insert_priority The priority to insert @a to_insert with.
101 */
102RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert(
103  Chain_Control  *chain,
104  Thread_Control *to_insert,
105  unsigned int    insert_priority
106)
107{
108  _Chain_Insert_ordered_unprotected(
109    chain,
110    &to_insert->Object.Node,
111    &insert_priority,
112    _Scheduler_simple_Priority_less_equal
113  );
114}
115
116/**
117 * @brief Extracts the threads node.
118 *
119 * @param scheduler This parameter is unused.
120 * @param[in, out] the_thread The thread of which to extract the node out of its chain.
121 * @param node This parameter is unused.
122 */
123RTEMS_INLINE_ROUTINE void _Scheduler_simple_Extract(
124  const Scheduler_Control *scheduler,
125  Thread_Control          *the_thread,
126  Scheduler_Node          *node
127)
128{
129  (void) scheduler;
130  (void) node;
131
132  _Chain_Extract_unprotected( &the_thread->Object.Node );
133}
134
135/**
136 * @brief Scheduling decision logic.
137 *
138 * This kernel routine implements scheduling decision logic for the simple scheduler.
139 *
140 * @param[in, out] scheduler The scheduler instance.
141 * @param the_thread This parameter is unused.
142 * @param force_dispatch Indicates whether the dispatch happens also if
143 *      the currently executing thread is set as not preemptible.
144 */
145RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body(
146  const Scheduler_Control *scheduler,
147  Thread_Control          *the_thread,
148  bool                     force_dispatch
149)
150{
151  Scheduler_simple_Context *context =
152    _Scheduler_simple_Get_context( scheduler );
153  Thread_Control *heir = (Thread_Control *) _Chain_First( &context->Ready );
154
155  ( void ) the_thread;
156
157  _Scheduler_Update_heir( heir, force_dispatch );
158}
159
160/** @} */
161
162#ifdef __cplusplus
163}
164#endif
165
166#endif
167/* end of include file */
Note: See TracBrowser for help on using the repository browser.