Process.h 5.13 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
7
(C) 2004-2014 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

15
// On Linux, this works only with glibc 2.1+. On earlier versions
Hisham Muhammad's avatar
Hisham Muhammad committed
16
// 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

Hisham Muhammad's avatar
Hisham Muhammad committed
25
#include <sys/types.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
26

27
28
typedef struct Settings_ Settings;

29
30
31
32
33
34
#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

35
36
37
38
39
40
41
#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
42

Hisham Muhammad's avatar
Hisham Muhammad committed
43
#ifndef Process_isThread
44
#define Process_isThread(_process) (Process_isUserlandThread(_process) || Process_isKernelThread(_process))
Hisham Muhammad's avatar
Hisham Muhammad committed
45
46
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
47
48
49
50
51
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,
52
   USER, TIME, NLWP, TGID,
53
   #ifdef HAVE_OPENVZ
54
   CTID, VPID,
55
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
56
57
58
   #ifdef HAVE_VSERVER
   VXID,
   #endif
59
   #ifdef HAVE_TASKSTATS
60
   RCHAR, WCHAR, SYSCR, SYSCW, RBYTES, WBYTES, CNCLWB, IO_READ_RATE, IO_WRITE_RATE, IO_RATE,
61
   #endif
62
63
64
   #ifdef HAVE_CGROUP
   CGROUP,
   #endif
65
66
67
   #ifdef HAVE_OOM
   OOM,
   #endif
68
   IO_PRIORITY,
69
   LAST_PROCESSFIELD
Hisham Muhammad's avatar
Hisham Muhammad committed
70
71
72
73
74
75
76
77
78
} ProcessField;

struct ProcessList_;

typedef struct Process_ {
   Object super;

   struct ProcessList_ *pl;

Hisham Muhammad's avatar
Hisham Muhammad committed
79
   pid_t pid;
Hisham Muhammad's avatar
Hisham Muhammad committed
80
81
82
83
   char* comm;
   int indent;
   char state;
   bool tag;
Hisham Muhammad's avatar
Hisham Muhammad committed
84
   bool showChildren;
85
   bool show;
Hisham Muhammad's avatar
Hisham Muhammad committed
86
   pid_t ppid;
87
88
89
   unsigned int pgrp;
   unsigned int session;
   unsigned int tty_nr;
Hisham Muhammad's avatar
Hisham Muhammad committed
90
   pid_t tgid;
91
   int tpgid;
Hisham Muhammad's avatar
Hisham Muhammad committed
92
   unsigned long int flags;
Hisham Muhammad's avatar
Hisham Muhammad committed
93
94
95
96
97
98

   uid_t st_uid;
   float percent_cpu;
   float percent_mem;
   char* user;

99
100
101
102
   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
103
104
   long int priority;
   long int nice;
105
   long int nlwp;
Hisham Muhammad's avatar
Hisham Muhammad committed
106
107
   char starttime_show[8];
   time_t starttime_ctime;
Hisham Muhammad's avatar
Hisham Muhammad committed
108
109
110
111
112
113
114
115
116
117
118
119
120

   #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;   
121
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
122

Hisham Muhammad's avatar
Hisham Muhammad committed
123
   int processor;
124
125
126
127
128
129
130
   long m_size;
   long m_resident;
   long m_share;
   long m_trs;
   long m_drs;
   long m_lrs;
   long m_dt;
Hisham Muhammad's avatar
Hisham Muhammad committed
131

132
   #ifdef HAVE_OPENVZ
133
   unsigned int ctid;
134
135
   unsigned int vpid;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
136
137
138
   #ifdef HAVE_VSERVER
   unsigned int vxid;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
139

140
141
142
   #ifdef HAVE_CGROUP
   char* cgroup;
   #endif
143
144
145
   #ifdef HAVE_OOM
   unsigned int oom;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
146
147

   int exit_signal;
148
   int basenameOffset;
Hisham Muhammad's avatar
Hisham Muhammad committed
149
150
151
152
153
154
   bool updated;

   unsigned long int minflt;
   unsigned long int cminflt;
   unsigned long int majflt;
   unsigned long int cmajflt;
155
   #ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
   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

Hisham Muhammad's avatar
Hisham Muhammad committed
174
175
176
} Process;


Hisham Muhammad's avatar
Hisham Muhammad committed
177
extern const char *Process_fieldNames[];
Hisham Muhammad's avatar
Hisham Muhammad committed
178

179
180
extern const int Process_fieldFlags[];

Hisham Muhammad's avatar
Hisham Muhammad committed
181
extern const char *Process_fieldTitles[];
182

183

184
void Process_setupColumnWidths();
185

186
#define ONE_K 1024L
187
188
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
Hisham Muhammad's avatar
Hisham Muhammad committed
189

190
#define ONE_DECIMAL_K 1000L
Hisham Muhammad's avatar
Hisham Muhammad committed
191
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
192
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
Hisham Muhammad's avatar
Hisham Muhammad committed
193

194
void Process_done(Process* this);
Hisham Muhammad's avatar
Hisham Muhammad committed
195

196
197
extern ObjectClass Process_class;

198
void Process_init(Process* this, struct Settings_* settings, struct ProcessList_* pl);
199

Hisham Muhammad's avatar
Hisham Muhammad committed
200
201
void Process_toggleTag(Process* this);

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

204
205
bool Process_changePriorityBy(Process* this, size_t delta);

206
#ifdef HAVE_LIBHWLOC
207

208
Affinity* Process_getAffinity(Process* this);
209

210
bool Process_setAffinity(Process* this, Affinity* affinity);
211
212
213
214
215
216
217

#elif HAVE_NATIVE_AFFINITY

Affinity* Process_getAffinity(Process* this);

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

Hisham Muhammad's avatar
Hisham Muhammad committed
218
#endif
219

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

222
long Process_pidCompare(const void* v1, const void* v2);
223

224
long Process_compare(const void* v1, const void* v2);
Hisham Muhammad's avatar
Hisham Muhammad committed
225
226

#endif