diff options
author | Nathan Scott <nathans@redhat.com> | 2023-08-22 16:11:05 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2023-08-30 13:11:57 +1000 |
commit | 0f751e991d399769fb8d7800f7c4bccec2ca7f60 (patch) | |
tree | 34cd7838f7ebf51049816f9acb6a63cea175af06 /Scheduling.c | |
parent | 68f4f10f012d11bd57bb725fe4113b2af937fc1d (diff) |
Introduce Row and Table classes for screens beyond top-processes
This commit refactors the Process and ProcessList structures such
they each have a new parent - Row and Table, respectively. These
new classes handle screen updates relating to anything that could
be represented in tabular format, e.g. cgroups, filesystems, etc,
without us having to reimplement the display logic repeatedly for
each new entity.
Diffstat (limited to 'Scheduling.c')
-rw-r--r-- | Scheduling.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Scheduling.c b/Scheduling.c index 5ca49ae2..10846c0b 100644 --- a/Scheduling.c +++ b/Scheduling.c @@ -97,7 +97,7 @@ Panel* Scheduling_newPriorityPanel(int policy, int preSelectedPriority) { return this; } -bool Scheduling_setPolicy(Process* proc, Arg arg) { +static bool Scheduling_setPolicy(Process* p, Arg arg) { const SchedulingArg* sarg = arg.v; int policy = sarg->policy; @@ -112,13 +112,19 @@ bool Scheduling_setPolicy(Process* proc, Arg arg) { policy &= SCHED_RESET_ON_FORK; #endif - int r = sched_setscheduler(proc->pid, policy, ¶m); + int r = sched_setscheduler(Process_getPid(p), policy, ¶m); /* POSIX says on success the previous scheduling policy should be returned, * but Linux always returns 0. */ return r != -1; } +bool Scheduling_rowSetPolicy(Row* row, Arg arg) { + Process* p = (Process*) row; + assert(Object_isA((const Object*) p, (const ObjectClass*) &Process_class)); + return Scheduling_setPolicy(p, arg); +} + const char* Scheduling_formatPolicy(int policy) { #ifdef SCHED_RESET_ON_FORK policy = policy & ~SCHED_RESET_ON_FORK; @@ -149,6 +155,6 @@ const char* Scheduling_formatPolicy(int policy) { } void Scheduling_readProcessPolicy(Process* proc) { - proc->scheduling_policy = sched_getscheduler(proc->pid); + proc->scheduling_policy = sched_getscheduler(Process_getPid(proc)); } #endif /* SCHEDULER_SUPPORT */ |