summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-10-27 12:59:09 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-11-15 08:56:53 +0100
commit240a1f79b1fcb58b9ae7bfc393e1f890e4492683 (patch)
tree92c47fa4899b2f0a8306e32bc18d66fbbf6b216f /cpukit/score
parentscore: Do not shadow parameter (diff)
downloadrtems-240a1f79b1fcb58b9ae7bfc393e1f890e4492683.tar.bz2
score: Introduce CPU budget operations
This patch set replaces the CPU budget algorithm enumeration with a set of CPU budget operations which implement a particular CPU budget algorithm. This helps to hide the CPU budget algorithm implementation details from the general thread handling. The CPU budget callouts are turned into CPU budget operations. This slightly reduces the size of the thread control block. All schedulers used the default scheduler tick implementation. The tick scheduler operation is removed and the CPU budget operations are directly used in _Watchdog_Tick() if the executing thread uses a CPU budget algorithm. This is performance improvement for all threads which do not use a CPU budget algorithm (default behaviour).
Diffstat (limited to '')
-rw-r--r--cpukit/score/src/mpci.c1
-rw-r--r--cpukit/score/src/schedulercbs.c41
-rw-r--r--cpukit/score/src/schedulercbsattachthread.c5
-rw-r--r--cpukit/score/src/schedulercbsdetachthread.c20
-rw-r--r--cpukit/score/src/schedulercbsgetexecutiontime.c2
-rw-r--r--cpukit/score/src/schedulercbsgetremainingbudget.c2
-rw-r--r--cpukit/score/src/schedulercbsreleasejob.c2
-rw-r--r--cpukit/score/src/schedulercbsunblock.c2
-rw-r--r--cpukit/score/src/schedulerdefaulttick.c81
-rw-r--r--cpukit/score/src/threadcreateidle.c1
-rw-r--r--cpukit/score/src/threaddispatch.c11
-rw-r--r--cpukit/score/src/threadexhausttimeslice.c53
-rw-r--r--cpukit/score/src/threadinitialize.c12
-rw-r--r--cpukit/score/src/threadloadenv.c11
-rw-r--r--cpukit/score/src/threadresettimeslice.c91
-rw-r--r--cpukit/score/src/threadrestart.c4
-rw-r--r--cpukit/score/src/watchdogtick.c25
17 files changed, 242 insertions, 122 deletions
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index cb306c9763..63a7eb13ef 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -144,7 +144,6 @@ static void _MPCI_Create_server( void )
config.scheduler = &_Scheduler_Table[ 0 ];
config.name = _Objects_Build_name( 'M', 'P', 'C', 'I' );
config.priority = PRIORITY_PSEUDO_ISR;
- config.budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
config.is_fp = CPU_ALL_TASKS_ARE_FP;
config.stack_size = _Stack_Minimum()
+ _MPCI_Configuration.extra_mpci_receive_server_stack
diff --git a/cpukit/score/src/schedulercbs.c b/cpukit/score/src/schedulercbs.c
index 8e5bf86f27..bedaf8e1da 100644
--- a/cpukit/score/src/schedulercbs.c
+++ b/cpukit/score/src/schedulercbs.c
@@ -21,10 +21,17 @@
#endif
#include <rtems/score/schedulercbsimpl.h>
+#include <rtems/score/statesimpl.h>
+#include <rtems/score/threadcpubudget.h>
-void _Scheduler_CBS_Budget_callout(
- Thread_Control *the_thread
-)
+/**
+ * @brief Invoked when a limited time quantum is exceeded.
+ *
+ * This routine is invoked when a limited time quantum is exceeded.
+ *
+ * @param the_thread The thread that exceeded a limited time quantum.
+ */
+static void _Scheduler_CBS_Budget_callout( Thread_Control *the_thread )
{
Scheduler_CBS_Node *node;
Scheduler_CBS_Server_id server_id;
@@ -52,6 +59,34 @@ void _Scheduler_CBS_Budget_callout(
}
}
+static void _Scheduler_CBS_Budget_at_tick( Thread_Control *the_thread )
+{
+ uint32_t budget_available;
+
+ if ( !the_thread->is_preemptible ) {
+ return;
+ }
+
+ if ( !_States_Is_ready( the_thread->current_state ) ) {
+ return;
+ }
+
+ budget_available = the_thread->CPU_budget.available;
+
+ if ( budget_available == 1 ) {
+ the_thread->CPU_budget.available = 0;
+ _Scheduler_CBS_Budget_callout ( the_thread );
+ } else {
+ the_thread->CPU_budget.available = budget_available - 1;
+ }
+}
+
+const Thread_CPU_budget_operations _Scheduler_CBS_Budget = {
+ .at_tick = _Scheduler_CBS_Budget_at_tick,
+ .at_context_switch = _Thread_CPU_budget_do_nothing,
+ .initialize = _Thread_CPU_budget_do_nothing
+};
+
int _Scheduler_CBS_Initialize(void)
{
return SCHEDULER_CBS_OK;
diff --git a/cpukit/score/src/schedulercbsattachthread.c b/cpukit/score/src/schedulercbsattachthread.c
index 0cb59fa2e8..d6c5b3b9eb 100644
--- a/cpukit/score/src/schedulercbsattachthread.c
+++ b/cpukit/score/src/schedulercbsattachthread.c
@@ -64,9 +64,8 @@ int _Scheduler_CBS_Attach_thread (
server->task_id = task_id;
- the_thread->budget_callout = _Scheduler_CBS_Budget_callout;
- the_thread->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT;
- the_thread->is_preemptible = true;
+ the_thread->is_preemptible = true;
+ the_thread->CPU_budget.operations = &_Scheduler_CBS_Budget;
_ISR_lock_ISR_enable( &lock_context );
return SCHEDULER_CBS_OK;
diff --git a/cpukit/score/src/schedulercbsdetachthread.c b/cpukit/score/src/schedulercbsdetachthread.c
index 687b37804f..5aa5eeb7a2 100644
--- a/cpukit/score/src/schedulercbsdetachthread.c
+++ b/cpukit/score/src/schedulercbsdetachthread.c
@@ -28,10 +28,11 @@ int _Scheduler_CBS_Detach_thread (
rtems_id task_id
)
{
- Scheduler_CBS_Server *server;
- ISR_lock_Context lock_context;
- Thread_Control *the_thread;
- Scheduler_CBS_Node *node;
+ Scheduler_CBS_Server *server;
+ ISR_lock_Context lock_context;
+ Thread_Control *the_thread;
+ Scheduler_CBS_Node *node;
+ const Thread_CPU_budget_operations *cpu_budget_operations;
if ( server_id >= _Scheduler_CBS_Maximum_servers ) {
return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
@@ -58,9 +59,14 @@ int _Scheduler_CBS_Detach_thread (
server->task_id = -1;
- the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
- the_thread->budget_callout = the_thread->Start.budget_callout;
- the_thread->is_preemptible = the_thread->Start.is_preemptible;
+ the_thread->is_preemptible = the_thread->Start.is_preemptible;
+
+ cpu_budget_operations = the_thread->Start.cpu_budget_operations;
+ the_thread->CPU_budget.operations = cpu_budget_operations;
+
+ if ( cpu_budget_operations != NULL ) {
+ ( *cpu_budget_operations->initialize )( the_thread );
+ }
_ISR_lock_ISR_enable( &lock_context );
return SCHEDULER_CBS_OK;
diff --git a/cpukit/score/src/schedulercbsgetexecutiontime.c b/cpukit/score/src/schedulercbsgetexecutiontime.c
index 28709151c0..c8e999a788 100644
--- a/cpukit/score/src/schedulercbsgetexecutiontime.c
+++ b/cpukit/score/src/schedulercbsgetexecutiontime.c
@@ -51,7 +51,7 @@ int _Scheduler_CBS_Get_execution_time (
the_thread = _Thread_Get( server->task_id, &lock_context );
if ( the_thread != NULL ) {
- *exec_time = server->parameters.budget - the_thread->cpu_time_budget;
+ *exec_time = server->parameters.budget - the_thread->CPU_budget.available;
_ISR_lock_ISR_enable( &lock_context );
} else {
*exec_time = server->parameters.budget;
diff --git a/cpukit/score/src/schedulercbsgetremainingbudget.c b/cpukit/score/src/schedulercbsgetremainingbudget.c
index 5cb299d67e..338fd56190 100644
--- a/cpukit/score/src/schedulercbsgetremainingbudget.c
+++ b/cpukit/score/src/schedulercbsgetremainingbudget.c
@@ -50,7 +50,7 @@ int _Scheduler_CBS_Get_remaining_budget (
the_thread = _Thread_Get( server->task_id, &lock_context );
if ( the_thread != NULL ) {
- *remaining_budget = the_thread->cpu_time_budget;
+ *remaining_budget = the_thread->CPU_budget.available;
_ISR_lock_ISR_enable( &lock_context );
} else {
*remaining_budget = 0;
diff --git a/cpukit/score/src/schedulercbsreleasejob.c b/cpukit/score/src/schedulercbsreleasejob.c
index 376906b996..27ca33ad56 100644
--- a/cpukit/score/src/schedulercbsreleasejob.c
+++ b/cpukit/score/src/schedulercbsreleasejob.c
@@ -38,7 +38,7 @@ void _Scheduler_CBS_Release_job(
/* Budget replenishment for the next job. */
if ( serv_info != NULL ) {
- the_thread->cpu_time_budget = serv_info->parameters.budget;
+ the_thread->CPU_budget.available = serv_info->parameters.budget;
}
node->deadline_node = priority_node;
diff --git a/cpukit/score/src/schedulercbsunblock.c b/cpukit/score/src/schedulercbsunblock.c
index 700d7b1202..ca985150fb 100644
--- a/cpukit/score/src/schedulercbsunblock.c
+++ b/cpukit/score/src/schedulercbsunblock.c
@@ -50,7 +50,7 @@ void _Scheduler_CBS_Unblock(
if ( serv_info != NULL && ( priority & SCHEDULER_EDF_PRIO_MSB ) == 0 ) {
time_t deadline = serv_info->parameters.deadline;
time_t budget = serv_info->parameters.budget;
- uint32_t deadline_left = the_thread->cpu_time_budget;
+ uint32_t deadline_left = the_thread->CPU_budget.available;
Priority_Control budget_left = priority - _Watchdog_Ticks_since_boot;
if ( deadline * budget_left > budget * deadline_left ) {
diff --git a/cpukit/score/src/schedulerdefaulttick.c b/cpukit/score/src/schedulerdefaulttick.c
deleted file mode 100644
index f4b6ba8578..0000000000
--- a/cpukit/score/src/schedulerdefaulttick.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * @file
- *
- * @ingroup RTEMSScoreScheduler
- *
- * @brief This source file contains the implementation of
- * _Scheduler_default_Tick().
- */
-
-/*
- * COPYRIGHT (c) 1989-2009.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/score/schedulerimpl.h>
-#include <rtems/score/threadimpl.h>
-#include <rtems/score/smp.h>
-#include <rtems/config.h>
-
-void _Scheduler_default_Tick(
- const Scheduler_Control *scheduler,
- Thread_Control *executing
-)
-{
- (void) scheduler;
-
- /*
- * If the thread is not preemptible or is not ready, then
- * just return.
- */
-
- if ( !executing->is_preemptible )
- return;
-
- if ( !_States_Is_ready( executing->current_state ) )
- return;
-
- /*
- * The cpu budget algorithm determines what happens next.
- */
-
- switch ( executing->budget_algorithm ) {
- case THREAD_CPU_BUDGET_ALGORITHM_NONE:
- break;
-
- case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
- #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
- case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
- #endif
- if ( (int)(--executing->cpu_time_budget) <= 0 ) {
-
- /*
- * A yield performs the ready chain mechanics needed when
- * resetting a timeslice. If no other thread's are ready
- * at the priority of the currently executing thread, then the
- * executing thread's timeslice is reset. Otherwise, the
- * currently executing thread is placed at the rear of the
- * FIFO for this priority and a new heir is selected.
- */
- _Thread_Yield( executing );
- executing->cpu_time_budget =
- rtems_configuration_get_ticks_per_timeslice();
- }
- break;
-
- #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
- case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
- if ( --executing->cpu_time_budget == 0 )
- (*executing->budget_callout)( executing );
- break;
- #endif
- }
-}
diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c
index 86e117e70f..83d9bdcd8d 100644
--- a/cpukit/score/src/threadcreateidle.c
+++ b/cpukit/score/src/threadcreateidle.c
@@ -43,7 +43,6 @@ static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu )
config.scheduler,
config.scheduler->maximum_priority
);
- config.budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
config.name = _Objects_Build_name( 'I', 'D', 'L', 'E' );
config.is_fp = CPU_IDLE_TASK_IS_FP;
config.is_preemptible = true;
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index 1d317ad2b1..a53c8de2b0 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -275,7 +275,8 @@ void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level )
executing = cpu_self->executing;
do {
- Thread_Control *heir;
+ Thread_Control *heir;
+ const Thread_CPU_budget_operations *cpu_budget_operations;
level = _Thread_Preemption_intervention( executing, cpu_self, level );
heir = _Thread_Get_heir_and_make_it_executing( cpu_self );
@@ -292,8 +293,12 @@ void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level )
* Since heir and executing are not the same, we need to do a real
* context switch.
*/
- if ( heir->budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE )
- heir->cpu_time_budget = rtems_configuration_get_ticks_per_timeslice();
+
+ cpu_budget_operations = heir->CPU_budget.operations;
+
+ if ( cpu_budget_operations != NULL ) {
+ ( *cpu_budget_operations->at_context_switch )( heir );
+ }
_ISR_Local_enable( level );
diff --git a/cpukit/score/src/threadexhausttimeslice.c b/cpukit/score/src/threadexhausttimeslice.c
new file mode 100644
index 0000000000..f3f6924e44
--- /dev/null
+++ b/cpukit/score/src/threadexhausttimeslice.c
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreThread
+ *
+ * @brief This source file contains the definition of
+ * ::_Thread_CPU_budget_exhaust_timeslice and the implementation of
+ * _Thread_CPU_budget_do_nothing().
+ */
+
+/*
+ * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/threadcpubudget.h>
+
+void _Thread_CPU_budget_do_nothing( Thread_Control *the_thread )
+{
+ (void) the_thread;
+}
+
+const Thread_CPU_budget_operations _Thread_CPU_budget_exhaust_timeslice = {
+ .at_tick = _Thread_CPU_budget_consume_and_yield,
+ .at_context_switch = _Thread_CPU_budget_do_nothing,
+ .initialize = _Thread_CPU_budget_set_to_ticks_per_timeslice
+};
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 81199a7044..01ef479537 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -274,13 +274,11 @@ static bool _Thread_Try_initialize(
* General initialization
*/
- the_thread->is_fp = config->is_fp;
- the_thread->cpu_time_budget = config->cpu_time_budget;
- the_thread->Start.isr_level = config->isr_level;
- the_thread->Start.is_preemptible = config->is_preemptible;
- the_thread->Start.budget_algorithm = config->budget_algorithm;
- the_thread->Start.budget_callout = config->budget_callout;
- the_thread->Start.stack_free = config->stack_free;
+ the_thread->is_fp = config->is_fp;
+ the_thread->Start.isr_level = config->isr_level;
+ the_thread->Start.is_preemptible = config->is_preemptible;
+ the_thread->Start.cpu_budget_operations = config->cpu_budget_operations;
+ the_thread->Start.stack_free = config->stack_free;
_Thread_Timer_initialize( &the_thread->Timer, cpu );
_Thread_Initialize_scheduler_and_wait_nodes( the_thread, config );
diff --git a/cpukit/score/src/threadloadenv.c b/cpukit/score/src/threadloadenv.c
index fec2a616d8..49317421b3 100644
--- a/cpukit/score/src/threadloadenv.c
+++ b/cpukit/score/src/threadloadenv.c
@@ -26,6 +26,8 @@ void _Thread_Load_environment(
Thread_Control *the_thread
)
{
+ const Thread_CPU_budget_operations *cpu_budget_operations;
+
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
if ( the_thread->Start.fp_context ) {
the_thread->fp_context = the_thread->Start.fp_context;
@@ -34,8 +36,13 @@ void _Thread_Load_environment(
#endif
the_thread->is_preemptible = the_thread->Start.is_preemptible;
- the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
- the_thread->budget_callout = the_thread->Start.budget_callout;
+
+ cpu_budget_operations = the_thread->Start.cpu_budget_operations;
+ the_thread->CPU_budget.operations = cpu_budget_operations;
+
+ if ( cpu_budget_operations != NULL ) {
+ ( *cpu_budget_operations->initialize )( the_thread );
+ }
_Context_Initialize(
&the_thread->Registers,
diff --git a/cpukit/score/src/threadresettimeslice.c b/cpukit/score/src/threadresettimeslice.c
new file mode 100644
index 0000000000..ed4d6fb3e3
--- /dev/null
+++ b/cpukit/score/src/threadresettimeslice.c
@@ -0,0 +1,91 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreThread
+ *
+ * @brief This source file contains the definition of
+ * ::_Thread_CPU_budget_reset_timeslice and the implementation of
+ * _Thread_CPU_budget_consume_and_yield() and
+ * _Thread_CPU_budget_set_to_ticks_per_timeslice().
+ */
+
+/*
+ * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2010 Gedare Bloom <gedare@rtems.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/threadcpubudget.h>
+#include <rtems/score/threadimpl.h>
+#include <rtems/score/statesimpl.h>
+#include <rtems/score/watchdogticks.h>
+
+void _Thread_CPU_budget_consume_and_yield( Thread_Control *the_thread )
+{
+ uint32_t budget_available;
+
+ if ( !the_thread->is_preemptible ) {
+ return;
+ }
+
+ if ( !_States_Is_ready( the_thread->current_state ) ) {
+ return;
+ }
+
+ budget_available = the_thread->CPU_budget.available;
+
+ if ( budget_available == 1 ) {
+ the_thread->CPU_budget.available = _Watchdog_Ticks_per_timeslice;
+
+ /*
+ * A yield performs the ready chain mechanics needed when
+ * resetting a timeslice. If no other thread's are ready
+ * at the priority of the currently executing thread, then the
+ * executing thread's timeslice is reset. Otherwise, the
+ * currently executing thread is placed at the rear of the
+ * FIFO for this priority and a new heir is selected.
+ */
+ _Thread_Yield( the_thread );
+ } else {
+ the_thread->CPU_budget.available = budget_available - 1;
+ }
+}
+
+void _Thread_CPU_budget_set_to_ticks_per_timeslice(
+ Thread_Control *the_thread
+)
+{
+ the_thread->CPU_budget.available = _Watchdog_Ticks_per_timeslice;
+}
+
+const Thread_CPU_budget_operations _Thread_CPU_budget_reset_timeslice = {
+ .at_tick = _Thread_CPU_budget_consume_and_yield,
+ .at_context_switch = _Thread_CPU_budget_set_to_ticks_per_timeslice,
+ .initialize = _Thread_CPU_budget_set_to_ticks_per_timeslice
+};
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 2240d8f713..15e141b51e 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -217,10 +217,6 @@ static Thread_Life_state _Thread_Change_life_locked(
_Thread_Is_life_change_allowed( state )
&& _Thread_Is_life_changing( state )
) {
- the_thread->is_preemptible = the_thread->Start.is_preemptible;
- the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
- the_thread->budget_callout = the_thread->Start.budget_callout;
-
_Thread_Add_post_switch_action(
the_thread,
&the_thread->Life.Action,
diff --git a/cpukit/score/src/watchdogtick.c b/cpukit/score/src/watchdogtick.c
index e77ca4e1e1..aa2efc3626 100644
--- a/cpukit/score/src/watchdogtick.c
+++ b/cpukit/score/src/watchdogtick.c
@@ -62,11 +62,13 @@ void _Watchdog_Do_tickle(
void _Watchdog_Tick( Per_CPU_Control *cpu )
{
- ISR_lock_Context lock_context;
- Watchdog_Header *header;
- Watchdog_Control *first;
- uint64_t ticks;
- struct timespec now;
+ ISR_lock_Context lock_context;
+ Watchdog_Header *header;
+ Watchdog_Control *first;
+ uint64_t ticks;
+ struct timespec now;
+ Thread_Control *executing;
+ const Thread_CPU_budget_operations *cpu_budget_operations;
if ( _Per_CPU_Is_boot_processor( cpu ) ) {
++_Watchdog_Ticks_since_boot;
@@ -122,5 +124,16 @@ void _Watchdog_Tick( Per_CPU_Control *cpu )
_ISR_lock_Release_and_ISR_enable( &cpu->Watchdog.Lock, &lock_context );
- _Scheduler_Tick( cpu );
+ /*
+ * Each online processor has at least an idle thread as the executing thread
+ * even in case it has currently no scheduler assigned. Clock interrupts on
+ * processors which are not online would be a severe bug of the Clock Driver.
+ */
+ executing = _Per_CPU_Get_executing( cpu );
+ _Assert( executing != NULL );
+ cpu_budget_operations = executing->CPU_budget.operations;
+
+ if ( cpu_budget_operations != NULL ) {
+ ( *cpu_budget_operations->at_tick )( executing );
+ }
}