aboutsummaryrefslogtreecommitdiffstats
path: root/Process.h
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
commitff9409b1737627857eb47f64f536a3f66b6a09a4 (patch)
tree61b631ba551e68a4f656b8b76ff7bd0d9955fc64 /Process.h
parentf75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff)
downloaddebian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.gz
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.bz2
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.zip
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'Process.h')
-rw-r--r--Process.h211
1 files changed, 84 insertions, 127 deletions
diff --git a/Process.h b/Process.h
index 19083fd..c9aa3e1 100644
--- a/Process.h
+++ b/Process.h
@@ -4,15 +4,17 @@
#define HEADER_Process
/*
htop - Process.h
-(C) 2004-2011 Hisham H. Muhammad
+(C) 2004-2015 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
-#ifdef HAVE_LIBHWLOC
+#ifdef __ANDROID__
+#define SYS_ioprio_get __NR_ioprio_get
+#define SYS_ioprio_set __NR_ioprio_set
#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) )
@@ -20,137 +22,87 @@ in the source distribution for its full text.
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
#include "Object.h"
-#include "Affinity.h"
-#include "IOPriority.h"
-#include <sys/types.h>
-
-#define PROCESS_FLAG_IO 1
-#define PROCESS_FLAG_IOPRIO 2
-#define PROCESS_FLAG_OPENVZ 4
-#define PROCESS_FLAG_VSERVER 8
-#define PROCESS_FLAG_CGROUP 16
-
-#ifndef Process_isKernelThread
-#define Process_isKernelThread(_process) (_process->pgrp == 0)
-#endif
-
-#ifndef Process_isUserlandThread
-#define Process_isUserlandThread(_process) (_process->pid != _process->tgid)
-#endif
-#ifndef Process_isThread
-#define Process_isThread(_process) (Process_isUserlandThread(_process) || Process_isKernelThread(_process))
-#endif
+#include <sys/types.h>
-typedef enum ProcessField_ {
- PID = 1, COMM, STATE, PPID, PGRP, SESSION, TTY_NR, TPGID, FLAGS, MINFLT, CMINFLT, MAJFLT, CMAJFLT, UTIME,
- STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
- STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
- PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
- USER, TIME, NLWP, TGID,
- #ifdef HAVE_OPENVZ
- CTID, VPID,
- #endif
- #ifdef HAVE_VSERVER
- VXID,
- #endif
- #ifdef HAVE_TASKSTATS
- RCHAR, WCHAR, SYSCR, SYSCW, RBYTES, WBYTES, CNCLWB, IO_READ_RATE, IO_WRITE_RATE, IO_RATE,
- #endif
- #ifdef HAVE_CGROUP
- CGROUP,
- #endif
- #ifdef HAVE_OOM
- OOM,
- #endif
- IO_PRIORITY,
- LAST_PROCESSFIELD
+#define PROCESS_FLAG_IO 0x0001
+
+typedef enum ProcessFields {
+ PID = 1,
+ COMM = 2,
+ STATE = 3,
+ PPID = 4,
+ PGRP = 5,
+ SESSION = 6,
+ TTY_NR = 7,
+ TPGID = 8,
+ MINFLT = 10,
+ MAJFLT = 12,
+ PRIORITY = 18,
+ NICE = 19,
+ STARTTIME = 21,
+ PROCESSOR = 38,
+ M_SIZE = 39,
+ M_RESIDENT = 40,
+ ST_UID = 46,
+ PERCENT_CPU = 47,
+ PERCENT_MEM = 48,
+ USER = 49,
+ TIME = 50,
+ NLWP = 51,
+ TGID = 52,
} ProcessField;
-struct ProcessList_;
+typedef struct ProcessPidColumn_ {
+ int id;
+ char* label;
+} ProcessPidColumn;
typedef struct Process_ {
Object super;
- struct ProcessList_ *pl;
+ struct Settings_* settings;
+ unsigned long long int time;
pid_t pid;
+ pid_t ppid;
+ pid_t tgid;
char* comm;
+ int commLen;
int indent;
+
+ int basenameOffset;
+ bool updated;
+
char state;
bool tag;
bool showChildren;
bool show;
- pid_t ppid;
unsigned int pgrp;
unsigned int session;
unsigned int tty_nr;
- pid_t tgid;
int tpgid;
+ uid_t st_uid;
unsigned long int flags;
+ int processor;
- uid_t st_uid;
float percent_cpu;
float percent_mem;
char* user;
- unsigned long long int utime;
- unsigned long long int stime;
- unsigned long long int cutime;
- unsigned long long int cstime;
long int priority;
long int nice;
long int nlwp;
- IOPriority ioPriority;
char starttime_show[8];
time_t starttime_ctime;
- #ifdef HAVE_TASKSTATS
- unsigned long long io_rchar;
- unsigned long long io_wchar;
- unsigned long long io_syscr;
- unsigned long long io_syscw;
- unsigned long long io_read_bytes;
- unsigned long long io_write_bytes;
- unsigned long long io_cancelled_write_bytes;
- double io_rate_read_bps;
- unsigned long long io_rate_read_time;
- double io_rate_write_bps;
- unsigned long long io_rate_write_time;
- #endif
-
- int processor;
long m_size;
long m_resident;
- long m_share;
- long m_trs;
- long m_drs;
- long m_lrs;
- long m_dt;
-
- #ifdef HAVE_OPENVZ
- unsigned int ctid;
- unsigned int vpid;
- #endif
- #ifdef HAVE_VSERVER
- unsigned int vxid;
- #endif
-
- #ifdef HAVE_CGROUP
- char* cgroup;
- #endif
- #ifdef HAVE_OOM
- unsigned int oom;
- #endif
int exit_signal;
- int basenameOffset;
- bool updated;
unsigned long int minflt;
- unsigned long int cminflt;
unsigned long int majflt;
- unsigned long int cmajflt;
#ifdef DEBUG
long int itrealvalue;
unsigned long int vsize;
@@ -172,15 +124,32 @@ typedef struct Process_ {
} Process;
+typedef struct ProcessFieldData_ {
+ const char* name;
+ const char* title;
+ const char* description;
+ int flags;
+} ProcessFieldData;
-extern const char *Process_fieldNames[];
+// Implemented in platform-specific code:
+void Process_writeField(Process* this, RichString* str, ProcessField field);
+long Process_compare(const void* v1, const void* v2);
+void Process_delete(Object* cast);
+bool Process_isThread(Process* this);
+extern ProcessFieldData Process_fields[];
+extern ProcessPidColumn Process_pidColumns[];
+extern char Process_pidFormat[20];
-extern const int Process_fieldFlags[];
+typedef Process*(*Process_New)(struct Settings_*);
+typedef void (*Process_WriteField)(Process*, RichString*, ProcessField);
-extern const char *Process_fieldTitles[];
+typedef struct ProcessClass_ {
+ const ObjectClass super;
+ const Process_WriteField writeField;
+} ProcessClass;
+#define As_Process(this_) ((ProcessClass*)((this_)->super.klass))
-void Process_getMaxPid();
#define ONE_K 1024L
#define ONE_M (ONE_K * ONE_K)
@@ -190,50 +159,38 @@ void Process_getMaxPid();
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
-void Process_delete(Object* cast);
+extern char Process_pidFormat[20];
-extern ObjectClass Process_class;
+void Process_setupColumnWidths();
-Process* Process_new(struct ProcessList_ *pl);
+void Process_humanNumber(RichString* str, unsigned long number, bool coloring);
-void Process_toggleTag(Process* this);
-
-bool Process_setPriority(Process* this, int priority);
+void Process_colorNumber(RichString* str, unsigned long long number, bool coloring);
-bool Process_changePriorityBy(Process* this, size_t delta);
+void Process_printTime(RichString* str, unsigned long long totalHundredths);
-IOPriority Process_updateIOPriority(Process* this);
+void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring);
-bool Process_setIOPriority(Process* this, IOPriority ioprio);
+void Process_writeField(Process* this, RichString* str, ProcessField field);
-/*
-[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:
-extern io_priority;
-*/
-#define Process_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->nice + 20) / 5) : p_->ioPriority)
+void Process_display(Object* cast, RichString* out);
-#ifdef HAVE_LIBHWLOC
+void Process_done(Process* this);
-Affinity* Process_getAffinity(Process* this);
+extern ProcessClass Process_class;
-bool Process_setAffinity(Process* this, Affinity* affinity);
+void Process_init(Process* this, struct Settings_* settings);
-#elif HAVE_NATIVE_AFFINITY
-
-Affinity* Process_getAffinity(Process* this);
+void Process_toggleTag(Process* this);
-bool Process_setAffinity(Process* this, Affinity* affinity);
+bool Process_setPriority(Process* this, int priority);
-#endif
+bool Process_changePriorityBy(Process* this, size_t delta);
void Process_sendSignal(Process* this, size_t sgn);
-int Process_pidCompare(const void* v1, const void* v2);
+long Process_pidCompare(const void* v1, const void* v2);
-int Process_compare(const void* v1, const void* v2);
+long Process_compare(const void* v1, const void* v2);
#endif

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