summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadexhausttimeslice.c
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/src/threadexhausttimeslice.c
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 'cpukit/score/src/threadexhausttimeslice.c')
-rw-r--r--cpukit/score/src/threadexhausttimeslice.c53
1 files changed, 53 insertions, 0 deletions
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
+};