"Fossies" - the Fresh Open Source Software Archive 
Member "atop-2.8.1/photoproc.h" (7 Jan 2023, 7167 Bytes) of package /linux/misc/atop-2.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "photoproc.h" see the
Fossies "Dox" file reference documentation and the last
Fossies "Diffs" side-by-side code changes report:
2.7.1_vs_2.8.0.
1 /*
2 ** ATOP - System & Process Monitor
3 **
4 ** The program 'atop' offers the possibility to view the activity of
5 ** the system on system-level as well as process-level.
6 **
7 ** Include-file describing process-level counters maintained and functions
8 ** to access the process-database.
9 ** ================================================================
10 ** Author: Gerlof Langeveld
11 ** E-mail: gerlof.langeveld@atoptool.nl
12 ** Date: November 1996
13 ** LINUX-port: June 2000
14 **
15 ** This program is free software; you can redistribute it and/or modify it
16 ** under the terms of the GNU General Public License as published by the
17 ** Free Software Foundation; either version 2, or (at your option) any
18 ** later version.
19 **
20 ** This program is distributed in the hope that it will be useful, but
21 ** WITHOUT ANY WARRANTY; without even the implied warranty of
22 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 ** See the GNU General Public License for more details.
24 */
25
26 #define PNAMLEN 15
27 #define CMDLEN 255
28 #define CGRLEN 64
29
30 /*
31 ** structure containing only relevant process-info extracted
32 ** from kernel's process-administration
33 */
34 struct tstat {
35 /* GENERAL TASK INFO */
36 struct gen {
37 int tgid; /* threadgroup identification */
38 int pid; /* process identification */
39 int ppid; /* parent process identification*/
40 int ruid; /* real user identification */
41 int euid; /* eff. user identification */
42 int suid; /* saved user identification */
43 int fsuid; /* fs user identification */
44 int rgid; /* real group identification */
45 int egid; /* eff. group identification */
46 int sgid; /* saved group identification */
47 int fsgid; /* fs group identification */
48 int nthr; /* number of threads in tgroup */
49 char name[PNAMLEN+1];/* process name string */
50 char isproc; /* boolean: process level? */
51 char state; /* process state ('E' = exited) */
52 int excode; /* process exit status */
53 time_t btime; /* process start time (epoch) */
54 time_t elaps; /* process elaps time (hertz) */
55 char cmdline[CMDLEN+1];/* command-line string */
56 int nthrslpi; /* # threads in state 'S' */
57 int nthrslpu; /* # threads in state 'D' */
58 int nthrrun; /* # threads in state 'R' */
59
60 int ctid; /* OpenVZ container ID */
61 int vpid; /* OpenVZ virtual PID */
62
63 int wasinactive; /* boolean: task inactive */
64
65 char container[16]; /* Docker container id (12 pos) */
66 char cgpath[CGRLEN]; /* cgroup v2 path name */
67 } gen;
68
69 /* CPU STATISTICS */
70 struct cpu {
71 count_t utime; /* time user text (ticks) */
72 count_t stime; /* time system text (ticks) */
73 int nice; /* nice value */
74 int prio; /* priority */
75 int rtprio; /* realtime priority */
76 int policy; /* scheduling policy */
77 int curcpu; /* current processor */
78 int sleepavg; /* sleep average percentage */
79 int cgcpuweight; /* cgroup cpu.weight */
80 int cgcpumax; /* cgroup cpu.max percentage */
81 int cgcpumaxr; /* restrictive percentage */
82 int ifuture[3]; /* reserved for future use */
83 char wchan[16]; /* wait channel string */
84 count_t rundelay; /* schedstat rundelay (nanosec) */
85 count_t blkdelay; /* blkio delay (ticks) */
86 count_t cfuture[3]; /* reserved for future use */
87 } cpu;
88
89 /* DISK STATISTICS */
90 struct dsk {
91 count_t rio; /* number of read requests */
92 count_t rsz; /* cumulative # sectors read */
93 count_t wio; /* number of write requests */
94 count_t wsz; /* cumulative # sectors written */
95 count_t cwsz; /* cumulative # written sectors */
96 /* being cancelled */
97 count_t cfuture[4]; /* reserved for future use */
98 } dsk;
99
100 /* MEMORY STATISTICS */
101 struct mem {
102 count_t minflt; /* number of page-reclaims */
103 count_t majflt; /* number of page-faults */
104 count_t vexec; /* virtmem execfile (Kb) */
105 count_t vmem; /* virtual memory (Kb) */
106 count_t rmem; /* resident memory (Kb) */
107 count_t pmem; /* resident memory (Kb) */
108 count_t vgrow; /* virtual growth (Kb) */
109 count_t rgrow; /* resident growth (Kb) */
110 count_t vdata; /* virtmem data (Kb) */
111 count_t vstack; /* virtmem stack (Kb) */
112 count_t vlibs; /* virtmem libexec (Kb) */
113 count_t vswap; /* swap space used (Kb) */
114 count_t vlock; /* virtual locked (Kb) */
115 count_t cgmemmax; /* cgroup memory.max (Kb) */
116 count_t cgmemmaxr; /* restrictive memory.max (Kb) */
117 count_t cgswpmax; /* cgroup memory.swap.max (Kb) */
118 count_t cgswpmaxr; /* restrictive swap.max (Kb) */
119 count_t cfuture[3]; /* reserved for future use */
120 } mem;
121
122 /* NETWORK STATISTICS */
123 struct net {
124 count_t tcpsnd; /* number of TCP-packets sent */
125 count_t tcpssz; /* cumulative size packets sent */
126 count_t tcprcv; /* number of TCP-packets recved */
127 count_t tcprsz; /* cumulative size packets rcvd */
128 count_t udpsnd; /* number of UDP-packets sent */
129 count_t udpssz; /* cumulative size packets sent */
130 count_t udprcv; /* number of UDP-packets recved */
131 count_t udprsz; /* cumulative size packets sent */
132 count_t avail1; /* */
133 count_t avail2; /* */
134 count_t cfuture[4]; /* reserved for future use */
135 } net;
136
137 struct gpu {
138 char state; // A - active, E - Exit, '\0' - no use
139 char cfuture[3]; //
140 short nrgpus; // number of GPUs for this process
141 int32_t gpulist; // bitlist with GPU numbers
142
143 int gpubusy; // gpu busy perc process lifetime -1 = n/a
144 int membusy; // memory busy perc process lifetime -1 = n/a
145 count_t timems; // milliseconds accounting -1 = n/a
146 // value 0 for active process,
147 // value > 0 after termination
148
149 count_t memnow; // current memory consumption in KiB
150 count_t memcum; // cumulative memory consumption in KiB
151 count_t sample; // number of samples
152 } gpu;
153 };
154
155
156 struct pinfo {
157 struct pinfo *phnext; /* next process in hash chain */
158 struct pinfo *prnext; /* next process in residue chain */
159 struct pinfo *prprev; /* prev process in residue chain */
160
161 struct tstat tstat; /* per-process statistics */
162 };
163
164 /*
165 ** structure to maintains all deviation info related to one sample
166 */
167 struct devtstat {
168 struct tstat *taskall;
169 struct tstat **procall;
170 struct tstat **procactive;
171
172 unsigned long ntaskall;
173 unsigned long ntaskactive;
174 unsigned long nprocall;
175 unsigned long nprocactive;
176
177 unsigned long totrun, totslpi, totslpu, totzombie;
178 };
179
180 /*
181 ** prototypes of process-database functions
182 */
183 int pdb_gettask(int, char, time_t, struct pinfo **);
184 void pdb_addtask(int, struct pinfo *);
185 int pdb_deltask(int, char);
186 int pdb_makeresidue(void);
187 int pdb_cleanresidue(void);
188 int pdb_srchresidue(struct tstat *, struct pinfo **);
189
190 /*
191 ** prototypes for raw process-statistics functions
192 */
193 struct netpertask;
194
195 void deviattask(struct tstat *, unsigned long,
196 struct tstat *, unsigned long,
197 struct devtstat *, struct sstat *);
198
199 unsigned long photoproc(struct tstat *, int);
200 unsigned long counttasks(void);