[PATCH 12/13] rtems: Add _Modes_Set_timeslice()
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Feb 17 19:30:27 UTC 2021
Update #4244.
---
cpukit/include/rtems/rtems/modesimpl.h | 15 +++++++++++++++
cpukit/rtems/src/taskmode.c | 8 +-------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/cpukit/include/rtems/rtems/modesimpl.h b/cpukit/include/rtems/rtems/modesimpl.h
index 5677c7f13d..f6711b4c2d 100644
--- a/cpukit/include/rtems/rtems/modesimpl.h
+++ b/cpukit/include/rtems/rtems/modesimpl.h
@@ -20,6 +20,8 @@
#include <rtems/rtems/modes.h>
#include <rtems/score/isrlevel.h>
+#include <rtems/score/thread.h>
+#include <rtems/config.h>
#ifdef __cplusplus
extern "C" {
@@ -99,6 +101,19 @@ RTEMS_INLINE_ROUTINE void _Modes_Set_interrupt_level (
_ISR_Set_level( _Modes_Get_interrupt_level( mode_set ) );
}
+RTEMS_INLINE_ROUTINE void _Modes_Set_timeslice(
+ Thread_Control *executing,
+ rtems_mode mode_set
+)
+{
+ if ( _Modes_Is_timeslice( mode_set ) ) {
+ executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
+ executing->cpu_time_budget = rtems_configuration_get_ticks_per_timeslice();
+ } else {
+ executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
+ }
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/rtems/src/taskmode.c b/cpukit/rtems/src/taskmode.c
index 24905368c3..197f5e1556 100644
--- a/cpukit/rtems/src/taskmode.c
+++ b/cpukit/rtems/src/taskmode.c
@@ -26,7 +26,6 @@
#include <rtems/score/schedulerimpl.h>
#include <rtems/score/smpimpl.h>
#include <rtems/score/threadimpl.h>
-#include <rtems/config.h>
rtems_status_code rtems_task_mode(
rtems_mode mode_set,
@@ -104,12 +103,7 @@ rtems_status_code rtems_task_mode(
}
if ( mask & RTEMS_TIMESLICE_MASK ) {
- if ( _Modes_Is_timeslice(mode_set) ) {
- executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
- executing->cpu_time_budget =
- rtems_configuration_get_ticks_per_timeslice();
- } else
- executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
+ _Modes_Set_timeslice( executing, mode_set );
}
/*
--
2.26.2
More information about the devel
mailing list