Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
ff4d1b46
Commit
ff4d1b46
authored
Nov 27, 2014
by
Hisham Muhammad
Browse files
Build fixes.
parent
6afacee5
Changes
1
Show whitespace changes
Inline
Side-by-side
linux/LinuxProcessList.c
View file @
ff4d1b46
...
...
@@ -572,13 +572,12 @@ static bool LinuxProcessList_processEntries(ProcessList* this, const char* dirna
}
static
inline
void
LinuxProcessList_scanMemoryInfo
(
ProcessList
*
this
)
{
unsigned
long
long
int
swapFree
=
0
;
FILE
*
file
=
fopen
(
PROCMEMINFOFILE
,
"r"
);
if
(
file
==
NULL
)
{
CRT_fatalError
(
"Cannot open "
PROCMEMINFOFILE
);
}
int
cpus
=
this
->
cpuCount
;
assert
(
cpus
>
0
);
{
char
buffer
[
128
];
while
(
fgets
(
buffer
,
128
,
file
))
{
...
...
@@ -607,18 +606,21 @@ static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) {
break
;
}
}
}
this
->
usedMem
=
this
->
totalMem
-
this
->
freeMem
;
this
->
usedSwap
=
this
->
totalSwap
-
swapFree
;
fclose
(
file
);
}
static
inline
double
LinuxProcessList_readCPUTime
(
ProcessList
*
this
)
{
static
inline
double
LinuxProcessList_scanCPUTime
(
ProcessList
*
this
)
{
unsigned
long
long
int
usertime
,
nicetime
,
systemtime
,
idletime
;
FILE
*
file
=
fopen
(
PROCSTATFILE
,
"r"
);
if
(
file
==
NULL
)
{
CRT_fatalError
(
"Cannot open "
PROCSTATFILE
);
}
int
cpus
=
this
->
cpuCount
;
assert
(
cpus
>
0
);
for
(
int
i
=
0
;
i
<=
cpus
;
i
++
)
{
char
buffer
[
256
];
int
cpuid
;
...
...
@@ -687,12 +689,10 @@ static inline double LinuxProcessList_readCPUTime(ProcessList* this) {
}
void
ProcessList_scan
(
ProcessList
*
this
)
{
unsigned
long
long
int
usertime
,
nicetime
,
systemtime
,
idletime
;
unsigned
long
long
int
swapFree
=
0
;
LinuxProcessList_scanMemoryInfo
(
this
);
LinuxProcessList_scanCPUTime
(
this
);
double
period
=
LinuxProcessList_scanCPUTime
(
this
);
// mark all process as "dirty"
for
(
int
i
=
0
;
i
<
Vector_size
(
this
->
processes
);
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment