Process.h 5.3 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
/* Do not edit this file. It was automatically generated. */
Hisham Muhammad's avatar
Hisham Muhammad committed
2
3
4
5
6

#ifndef HEADER_Process
#define HEADER_Process
/*
htop - Process.h
Hisham Muhammad's avatar
Hisham Muhammad committed
7
(C) 2004-2011 Hisham H. Muhammad
Hisham Muhammad's avatar
Hisham Muhammad committed
8
9
10
11
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

12
#ifdef HAVE_LIBHWLOC
Hisham Muhammad's avatar
Hisham Muhammad committed
13
#endif
14

Hisham Muhammad's avatar
Hisham Muhammad committed
15
16
// This works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size.
17
#ifndef PAGE_SIZE
Hisham Muhammad's avatar
Hisham Muhammad committed
18
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
19
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
20
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
Hisham Muhammad's avatar
Hisham Muhammad committed
21

Hisham Muhammad's avatar
Hisham Muhammad committed
22
23
#include "Object.h"
#include "Affinity.h"
24
#include "IOPriority.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
25
#include <sys/types.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
26

27
28
29
30
31
32
33
#ifndef Process_isKernelThread
#define Process_isKernelThread(_process) (_process->pgrp == 0)
#endif

#ifndef Process_isUserlandThread
#define Process_isUserlandThread(_process) (_process->pid != _process->tgid)
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
34

Hisham Muhammad's avatar
Hisham Muhammad committed
35
#ifndef Process_isThread
36
#define Process_isThread(_process) (Process_isUserlandThread(_process) || Process_isKernelThread(_process))
Hisham Muhammad's avatar
Hisham Muhammad committed
37
38
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
39
40
41
42
43
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,
44
   USER, TIME, NLWP, TGID,
45
   #ifdef HAVE_OPENVZ
46
   CTID, VPID,
47
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
48
49
50
   #ifdef HAVE_VSERVER
   VXID,
   #endif
51
   #ifdef HAVE_TASKSTATS
52
   RCHAR, WCHAR, SYSCR, SYSCW, RBYTES, WBYTES, CNCLWB, IO_READ_RATE, IO_WRITE_RATE, IO_RATE,
53
   #endif
54
55
56
   #ifdef HAVE_CGROUP
   CGROUP,
   #endif
57
   IO_PRIORITY,
58
   LAST_PROCESSFIELD
Hisham Muhammad's avatar
Hisham Muhammad committed
59
60
61
62
63
64
65
66
67
68
} ProcessField;

struct ProcessList_;

typedef struct Process_ {
   Object super;

   struct ProcessList_ *pl;
   bool updated;

Hisham Muhammad's avatar
Hisham Muhammad committed
69
   pid_t pid;
Hisham Muhammad's avatar
Hisham Muhammad committed
70
71
72
73
   char* comm;
   int indent;
   char state;
   bool tag;
Hisham Muhammad's avatar
Hisham Muhammad committed
74
   bool showChildren;
75
   bool show;
Hisham Muhammad's avatar
Hisham Muhammad committed
76
   pid_t ppid;
77
78
79
   unsigned int pgrp;
   unsigned int session;
   unsigned int tty_nr;
Hisham Muhammad's avatar
Hisham Muhammad committed
80
   pid_t tgid;
81
   int tpgid;
Hisham Muhammad's avatar
Hisham Muhammad committed
82
   unsigned long int flags;
83
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
84
85
86
87
   unsigned long int minflt;
   unsigned long int cminflt;
   unsigned long int majflt;
   unsigned long int cmajflt;
88
   #endif
89
90
91
92
   unsigned long long int utime;
   unsigned long long int stime;
   unsigned long long int cutime;
   unsigned long long int cstime;
Hisham Muhammad's avatar
Hisham Muhammad committed
93
94
   long int priority;
   long int nice;
95
   long int nlwp;
96
   IOPriority ioPriority;
Hisham Muhammad's avatar
Hisham Muhammad committed
97
98
   char starttime_show[8];
   time_t starttime_ctime;
99
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
   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;
116
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
117
118
119
120
121
122
123
124
125
126
127
128
   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;
129
   char* user;
130
   #ifdef HAVE_OPENVZ
131
   unsigned int ctid;
132
133
   unsigned int vpid;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
134
135
136
   #ifdef HAVE_VSERVER
   unsigned int vxid;
   #endif
137
138
139
140
141
142
143
144
145
146
147
148
149
   #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
150
151
152
   #ifdef HAVE_CGROUP
   char* cgroup;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
153
154
155
} Process;


Hisham Muhammad's avatar
Hisham Muhammad committed
156
extern const char *Process_fieldNames[];
Hisham Muhammad's avatar
Hisham Muhammad committed
157

Hisham Muhammad's avatar
Hisham Muhammad committed
158
extern const char *Process_fieldTitles[];
159

160
161
162

void Process_getMaxPid();

163
164
165
#define ONE_K 1024
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
Hisham Muhammad's avatar
Hisham Muhammad committed
166
167
168

void Process_delete(Object* cast);

169
170
extern ObjectClass Process_class;

171
172
Process* Process_new(struct ProcessList_ *pl);

Hisham Muhammad's avatar
Hisham Muhammad committed
173
174
void Process_toggleTag(Process* this);

175
bool Process_setPriority(Process* this, int priority);
Hisham Muhammad's avatar
Hisham Muhammad committed
176

177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
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)

193
#ifdef HAVE_LIBHWLOC
194

195
Affinity* Process_getAffinity(Process* this);
196

197
bool Process_setAffinity(Process* this, Affinity* affinity);
198
199
200
201
202
203
204

#elif HAVE_NATIVE_AFFINITY

Affinity* Process_getAffinity(Process* this);

bool Process_setAffinity(Process* this, Affinity* affinity);

Hisham Muhammad's avatar
Hisham Muhammad committed
205
#endif
206

207
void Process_sendSignal(Process* this, size_t sgn);
Hisham Muhammad's avatar
Hisham Muhammad committed
208

209
210
211
int Process_pidCompare(const void* v1, const void* v2);

int Process_compare(const void* v1, const void* v2);
Hisham Muhammad's avatar
Hisham Muhammad committed
212
213

#endif