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
6afacee5
Commit
6afacee5
authored
Nov 27, 2014
by
Hisham Muhammad
Browse files
A little refactoring
parent
a75161f8
Changes
1
Show whitespace changes
Inline
Side-by-side
linux/LinuxProcessList.c
View file @
6afacee5
...
@@ -571,10 +571,7 @@ static bool LinuxProcessList_processEntries(ProcessList* this, const char* dirna
...
@@ -571,10 +571,7 @@ static bool LinuxProcessList_processEntries(ProcessList* this, const char* dirna
return
true
;
return
true
;
}
}
void
ProcessList_scan
(
ProcessList
*
this
)
{
static
inline
void
LinuxProcessList_scanMemoryInfo
(
ProcessList
*
this
)
{
unsigned
long
long
int
usertime
,
nicetime
,
systemtime
,
idletime
;
unsigned
long
long
int
swapFree
=
0
;
FILE
*
file
=
fopen
(
PROCMEMINFOFILE
,
"r"
);
FILE
*
file
=
fopen
(
PROCMEMINFOFILE
,
"r"
);
if
(
file
==
NULL
)
{
if
(
file
==
NULL
)
{
CRT_fatalError
(
"Cannot open "
PROCMEMINFOFILE
);
CRT_fatalError
(
"Cannot open "
PROCMEMINFOFILE
);
...
@@ -615,8 +612,10 @@ void ProcessList_scan(ProcessList* this) {
...
@@ -615,8 +612,10 @@ void ProcessList_scan(ProcessList* this) {
this
->
usedMem
=
this
->
totalMem
-
this
->
freeMem
;
this
->
usedMem
=
this
->
totalMem
-
this
->
freeMem
;
this
->
usedSwap
=
this
->
totalSwap
-
swapFree
;
this
->
usedSwap
=
this
->
totalSwap
-
swapFree
;
fclose
(
file
);
fclose
(
file
);
}
file
=
fopen
(
PROCSTATFILE
,
"r"
);
static
inline
double
LinuxProcessList_readCPUTime
(
ProcessList
*
this
)
{
FILE
*
file
=
fopen
(
PROCSTATFILE
,
"r"
);
if
(
file
==
NULL
)
{
if
(
file
==
NULL
)
{
CRT_fatalError
(
"Cannot open "
PROCSTATFILE
);
CRT_fatalError
(
"Cannot open "
PROCSTATFILE
);
}
}
...
@@ -684,6 +683,16 @@ void ProcessList_scan(ProcessList* this) {
...
@@ -684,6 +683,16 @@ void ProcessList_scan(ProcessList* this) {
cpuData
->
totalTime
=
totaltime
;
cpuData
->
totalTime
=
totaltime
;
}
}
double
period
=
(
double
)
this
->
cpus
[
0
].
totalPeriod
/
cpus
;
fclose
(
file
);
double
period
=
(
double
)
this
->
cpus
[
0
].
totalPeriod
/
cpus
;
fclose
(
file
);
return
period
;
}
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
);
// mark all process as "dirty"
// mark all process as "dirty"
for
(
int
i
=
0
;
i
<
Vector_size
(
this
->
processes
);
i
++
)
{
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