summaryrefslogtreecommitdiffstats
path: root/Scheduling.h
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-01-10 19:40:04 +0100
committerBenBE <BenBE@geshi.org>2023-02-05 00:17:33 +0100
commitda494896914a327476ab7e0298619d742a6205d4 (patch)
tree700db7b14d148c492b1fb0295462fee2214239ed /Scheduling.h
parentf1da8cfa28cce46cc7a4ab1661be35e2173155ab (diff)
Add support for scheduling policies
Add a process column for scheduling policy to show the current scheduling policy of the process. Add a the ability to change the scheduling policy of a process via the key 'Y'. Currently implemented on Linux and FreeBSD only but should be portable, since sched_getscheduler(2) is part of POSIX.1-2001. Closes: #1161
Diffstat (limited to 'Scheduling.h')
-rw-r--r--Scheduling.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/Scheduling.h b/Scheduling.h
new file mode 100644
index 00000000..d91855ae
--- /dev/null
+++ b/Scheduling.h
@@ -0,0 +1,49 @@
+#ifndef HEADER_Scheduling
+#define HEADER_Scheduling
+/*
+htop - Scheduling.h
+(C) 2023 htop dev team
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "config.h" // IWYU pragma: keep
+
+#include <sched.h>
+#include <stdbool.h>
+
+#include "Panel.h"
+
+
+#if defined(HAVE_SCHED_SETSCHEDULER) && defined(HAVE_SCHED_GETSCHEDULER)
+#define SCHEDULER_SUPPORT
+
+typedef struct {
+ const char* name;
+ int id;
+ bool prioritySupport;
+} SchedulingPolicy;
+
+#define SCHEDULINGPANEL_INITSELECTEDPOLICY SCHED_OTHER
+#define SCHEDULINGPANEL_INITSELECTEDPRIORITY 50
+
+Panel* Scheduling_newPolicyPanel(int preSelectedPolicy);
+void Scheduling_togglePolicyPanelResetOnFork(Panel* schedPanel);
+
+Panel* Scheduling_newPriorityPanel(int policy, int preSelectedPriority);
+
+
+typedef struct {
+ int policy;
+ int priority;
+} SchedulingArg;
+
+bool Scheduling_setPolicy(Process* proc, Arg arg);
+
+const char* Scheduling_formatPolicy(int policy);
+
+void Scheduling_readProcessPolicy(Process* proc);
+
+#endif
+
+#endif /* HEADER_Scheduling */

© 2014-2024 Faster IT GmbH | imprint | privacy policy