diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-01-10 19:40:04 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2023-02-05 00:17:33 +0100 |
commit | da494896914a327476ab7e0298619d742a6205d4 (patch) | |
tree | 700db7b14d148c492b1fb0295462fee2214239ed /Process.c | |
parent | f1da8cfa28cce46cc7a4ab1661be35e2173155ab (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 'Process.c')
-rw-r--r-- | Process.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -28,6 +28,7 @@ in the source distribution for its full text. #include "ProcessList.h" #include "DynamicColumn.h" #include "RichString.h" +#include "Scheduling.h" #include "Settings.h" #include "XUtils.h" @@ -960,6 +961,15 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field xSnprintf(buffer, n, "%3ld ", this->priority); break; case PROCESSOR: xSnprintf(buffer, n, "%3d ", Settings_cpuId(this->settings, this->processor)); break; + case SCHEDULERPOLICY: { + const char* schedPolStr = "N/A"; +#ifdef SCHEDULER_SUPPORT + if (this->scheduling_policy >= 0) + schedPolStr = Scheduling_formatPolicy(this->scheduling_policy); +#endif + xSnprintf(buffer, n, "%-5s ", schedPolStr); + break; + } case SESSION: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->session); break; case STARTTIME: xSnprintf(buffer, n, "%s", this->starttime_show); break; case STATE: @@ -1203,6 +1213,8 @@ int Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField return SPACESHIP_NUMBER(p1->priority, p2->priority); case PROCESSOR: return SPACESHIP_NUMBER(p1->processor, p2->processor); + case SCHEDULERPOLICY: + return SPACESHIP_NUMBER(p1->scheduling_policy, p2->scheduling_policy); case SESSION: return SPACESHIP_NUMBER(p1->session, p2->session); case STARTTIME: |