htop/Process.h

218 lines
5.3 KiB
C
Raw Normal View History

2006-06-06 20:28:42 +00:00
/* Do not edit this file. It was automatically generated. */
2006-03-04 18:16:49 +00:00
#ifndef HEADER_Process
#define HEADER_Process
/*
htop - Process.h
2011-05-26 16:35:07 +00:00
(C) 2004-2011 Hisham H. Muhammad
2006-03-04 18:16:49 +00:00
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#ifdef HAVE_LIBHWLOC
#endif
2006-03-04 18:16:49 +00:00
// 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) )
#endif
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
2006-03-04 18:16:49 +00:00
2011-12-26 21:35:57 +00:00
#include "Object.h"
#include "Affinity.h"
2012-10-04 23:59:45 +00:00
#include "IOPriority.h"
2011-12-26 21:35:57 +00:00
#include <sys/types.h>
2006-03-04 18:16:49 +00:00
#ifndef Process_isKernelThread
#define Process_isKernelThread(_process) (_process->pgrp == 0)
#endif
#ifndef Process_isUserlandThread
#define Process_isUserlandThread(_process) (_process->pid != _process->tgid)
#endif
2006-03-04 18:16:49 +00:00
2010-02-22 20:57:25 +00:00
#ifndef Process_isThread
#define Process_isThread(_process) (Process_isUserlandThread(_process) || Process_isKernelThread(_process))
2010-02-22 20:57:25 +00:00
#endif
2006-03-04 18:16:49 +00:00
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
2012-10-04 23:59:45 +00:00
IO_PRIORITY,
LAST_PROCESSFIELD
2006-03-04 18:16:49 +00:00
} ProcessField;
struct ProcessList_;
typedef struct Process_ {
Object super;
struct ProcessList_ *pl;
bool updated;
2010-02-25 01:43:18 +00:00
pid_t pid;
2006-03-04 18:16:49 +00:00
char* comm;
int indent;
char state;
bool tag;
2010-06-17 19:02:03 +00:00
bool showChildren;
bool show;
2010-02-25 01:43:18 +00:00
pid_t ppid;
unsigned int pgrp;
unsigned int session;
unsigned int tty_nr;
2010-02-25 01:43:18 +00:00
pid_t tgid;
int tpgid;
2006-03-04 18:16:49 +00:00
unsigned long int flags;
#ifdef DEBUG
2006-03-04 18:16:49 +00:00
unsigned long int minflt;
unsigned long int cminflt;
unsigned long int majflt;
unsigned long int cmajflt;
#endif
2011-03-28 19:06:06 +00:00
unsigned long long int utime;
unsigned long long int stime;
unsigned long long int cutime;
unsigned long long int cstime;
2006-03-04 18:16:49 +00:00
long int priority;
long int nice;
long int nlwp;
2012-10-04 23:59:45 +00:00
IOPriority ioPriority;
2010-03-29 18:36:11 +00:00
char starttime_show[8];
time_t starttime_ctime;
#ifdef DEBUG
2006-03-04 18:16:49 +00:00
long int itrealvalue;
unsigned long int vsize;
long int rss;
unsigned long int rlim;
unsigned long int startcode;
unsigned long int endcode;
unsigned long int startstack;
unsigned long int kstkesp;
unsigned long int kstkeip;
unsigned long int signal;
unsigned long int blocked;
unsigned long int sigignore;
unsigned long int sigcatch;
unsigned long int wchan;
unsigned long int nswap;
unsigned long int cnswap;
#endif
2006-03-04 18:16:49 +00:00
int exit_signal;
int processor;
int m_size;
int m_resident;
int m_share;
int m_trs;
int m_drs;
int m_lrs;
int m_dt;
uid_t st_uid;
float percent_cpu;
float percent_mem;
2006-07-12 01:35:59 +00:00
char* user;
#ifdef HAVE_OPENVZ
unsigned int ctid;
unsigned int vpid;
#endif
#ifdef HAVE_VSERVER
unsigned int vxid;
#endif
#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
#ifdef HAVE_CGROUP
char* cgroup;
#endif
2006-03-04 18:16:49 +00:00
} Process;
#ifdef DEBUG
2006-06-06 20:28:42 +00:00
extern char* PROCESS_CLASS;
#else
#define PROCESS_CLASS NULL
#endif
2006-03-04 18:16:49 +00:00
2010-02-25 01:43:18 +00:00
extern const char *Process_fieldNames[];
2006-03-04 18:16:49 +00:00
2010-02-25 01:43:18 +00:00
extern const char *Process_fieldTitles[];
void Process_getMaxPid();
#define ONE_K 1024
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
2006-03-04 18:16:49 +00:00
void Process_delete(Object* cast);
Process* Process_new(struct ProcessList_ *pl);
2006-03-04 18:16:49 +00:00
void Process_toggleTag(Process* this);
bool Process_setPriority(Process* this, int priority);
2006-03-04 18:16:49 +00:00
2012-10-04 23:59:45 +00:00
bool Process_changePriorityBy(Process* this, size_t delta);
IOPriority Process_updateIOPriority(Process* this);
bool Process_setIOPriority(Process* this, IOPriority 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:
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)
#ifdef HAVE_LIBHWLOC
Affinity* Process_getAffinity(Process* this);
bool Process_setAffinity(Process* this, Affinity* affinity);
#elif HAVE_NATIVE_AFFINITY
Affinity* Process_getAffinity(Process* this);
bool Process_setAffinity(Process* this, Affinity* affinity);
#endif
2012-10-04 23:59:45 +00:00
void Process_sendSignal(Process* this, size_t sgn);
2006-03-04 18:16:49 +00:00
int Process_pidCompare(const void* v1, const void* v2);
int Process_compare(const void* v1, const void* v2);
2006-03-04 18:16:49 +00:00
#endif