mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Changes for supporting separate platform subdirectories.
This commit is contained in:
48
Process.c
48
Process.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
htop - Process.c
|
||||
(C) 2004-2011 Hisham H. Muhammad
|
||||
(C) 2004-2014 Hisham H. Muhammad
|
||||
Released under the GNU GPL, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
@ -32,7 +32,7 @@ in the source distribution for its full text.
|
||||
#include <hwloc/linux.h>
|
||||
#endif
|
||||
|
||||
// This works only with glibc 2.1+. On earlier versions
|
||||
// On Linux, this works only with glibc 2.1+. On earlier versions
|
||||
// the behavior is similar to have a hardcoded page size.
|
||||
#ifndef PAGE_SIZE
|
||||
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
|
||||
@ -42,7 +42,7 @@ in the source distribution for its full text.
|
||||
/*{
|
||||
#include "Object.h"
|
||||
#include "Affinity.h"
|
||||
#include "IOPriority.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define PROCESS_FLAG_IO 1
|
||||
@ -122,7 +122,6 @@ typedef struct Process_ {
|
||||
long int priority;
|
||||
long int nice;
|
||||
long int nlwp;
|
||||
IOPriority ioPriority;
|
||||
char starttime_show[8];
|
||||
time_t starttime_ctime;
|
||||
|
||||
@ -628,24 +627,6 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
|
||||
#ifdef HAVE_OOM
|
||||
case OOM: snprintf(buffer, n, Process_pidFormat, this->oom); break;
|
||||
#endif
|
||||
case IO_PRIORITY: {
|
||||
int klass = IOPriority_class(this->ioPriority);
|
||||
if (klass == IOPRIO_CLASS_NONE) {
|
||||
// see note [1] above
|
||||
snprintf(buffer, n, "B%1d ", (int) (this->nice + 20) / 5);
|
||||
} else if (klass == IOPRIO_CLASS_BE) {
|
||||
snprintf(buffer, n, "B%1d ", IOPriority_data(this->ioPriority));
|
||||
} else if (klass == IOPRIO_CLASS_RT) {
|
||||
attr = CRT_colors[PROCESS_HIGH_PRIORITY];
|
||||
snprintf(buffer, n, "R%1d ", IOPriority_data(this->ioPriority));
|
||||
} else if (this->ioPriority == IOPriority_Idle) {
|
||||
attr = CRT_colors[PROCESS_LOW_PRIORITY];
|
||||
snprintf(buffer, n, "id ");
|
||||
} else {
|
||||
snprintf(buffer, n, "?? ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
snprintf(buffer, n, "- ");
|
||||
}
|
||||
@ -720,27 +701,6 @@ bool Process_changePriorityBy(Process* this, size_t delta) {
|
||||
return Process_setPriority(this, this->nice + delta);
|
||||
}
|
||||
|
||||
IOPriority Process_updateIOPriority(Process* this) {
|
||||
IOPriority ioprio = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, this->pid);
|
||||
this->ioPriority = ioprio;
|
||||
return ioprio;
|
||||
}
|
||||
|
||||
bool Process_setIOPriority(Process* this, IOPriority ioprio) {
|
||||
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->pid, ioprio);
|
||||
return (Process_updateIOPriority(this) == ioprio);
|
||||
}
|
||||
|
||||
/*
|
||||
[1] Note that before kernel 2.6.26 a process that has not asked for
|
||||
an io priority formally uses "none" as scheduling class, but the
|
||||
io scheduler will treat such processes as if it were in the best
|
||||
effort class. The priority within the best effort class will be
|
||||
dynamically derived from the cpu nice level of the process:
|
||||
io_priority = (cpu_nice + 20) / 5. -- From ionice(1) man page
|
||||
*/
|
||||
#define Process_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->nice + 20) / 5) : p_->ioPriority)
|
||||
|
||||
#ifdef HAVE_LIBHWLOC
|
||||
|
||||
Affinity* Process_getAffinity(Process* this) {
|
||||
@ -902,8 +862,6 @@ long Process_compare(const void* v1, const void* v2) {
|
||||
case OOM:
|
||||
return (p1->oom - p2->oom);
|
||||
#endif
|
||||
case IO_PRIORITY:
|
||||
return Process_effectiveIOPriority(p1) - Process_effectiveIOPriority(p2);
|
||||
default:
|
||||
return (p1->pid - p2->pid);
|
||||
}
|
||||
|
Reference in New Issue
Block a user