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
f70649a1
Commit
f70649a1
authored
Aug 19, 2015
by
Hisham Muhammad
Browse files
Standardize indentation.
parent
907f8298
Changes
4
Hide whitespace changes
Inline
Side-by-side
darwin/Battery.c
View file @
f70649a1
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include <IOKit/ps/IOPSKeys.h>
#include <IOKit/ps/IOPSKeys.h>
void
Battery_getData
(
double
*
level
,
ACPresence
*
isOnAC
)
{
void
Battery_getData
(
double
*
level
,
ACPresence
*
isOnAC
)
{
CFTypeRef
power_sources
=
IOPSCopyPowerSourcesInfo
();
CFTypeRef
power_sources
=
IOPSCopyPowerSourcesInfo
();
*
level
=
-
1
;
*
level
=
-
1
;
*
isOnAC
=
AC_ERROR
;
*
isOnAC
=
AC_ERROR
;
...
@@ -22,50 +22,50 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
...
@@ -22,50 +22,50 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
int
len
;
int
len
;
if
(
NULL
==
list
)
{
if
(
NULL
==
list
)
{
CFRelease
(
power_sources
);
CFRelease
(
power_sources
);
return
;
return
;
}
}
len
=
CFArrayGetCount
(
list
);
len
=
CFArrayGetCount
(
list
);
/* Get the battery */
/* Get the battery */
for
(
int
i
=
0
;
i
<
len
&&
battery
==
NULL
;
++
i
)
{
for
(
int
i
=
0
;
i
<
len
&&
battery
==
NULL
;
++
i
)
{
CFDictionaryRef
candidate
=
IOPSGetPowerSourceDescription
(
power_sources
,
CFDictionaryRef
candidate
=
IOPSGetPowerSourceDescription
(
power_sources
,
CFArrayGetValueAtIndex
(
list
,
i
));
/* GET rule */
CFArrayGetValueAtIndex
(
list
,
i
));
/* GET rule */
CFStringRef
type
;
CFStringRef
type
;
if
(
NULL
!=
candidate
)
{
if
(
NULL
!=
candidate
)
{
type
=
(
CFStringRef
)
CFDictionaryGetValue
(
candidate
,
type
=
(
CFStringRef
)
CFDictionaryGetValue
(
candidate
,
CFSTR
(
kIOPSTransportTypeKey
));
/* GET rule */
CFSTR
(
kIOPSTransportTypeKey
));
/* GET rule */
if
(
kCFCompareEqualTo
==
CFStringCompare
(
type
,
CFSTR
(
kIOPSInternalType
),
0
))
{
if
(
kCFCompareEqualTo
==
CFStringCompare
(
type
,
CFSTR
(
kIOPSInternalType
),
0
))
{
CFRetain
(
candidate
);
CFRetain
(
candidate
);
battery
=
candidate
;
battery
=
candidate
;
}
}
}
}
}
}
if
(
NULL
!=
battery
)
{
if
(
NULL
!=
battery
)
{
/* Determine the AC state */
/* Determine the AC state */
CFStringRef
power_state
=
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOPSPowerSourceStateKey
));
CFStringRef
power_state
=
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOPSPowerSourceStateKey
));
*
isOnAC
=
(
kCFCompareEqualTo
==
CFStringCompare
(
power_state
,
CFSTR
(
kIOPSACPowerValue
),
0
))
*
isOnAC
=
(
kCFCompareEqualTo
==
CFStringCompare
(
power_state
,
CFSTR
(
kIOPSACPowerValue
),
0
))
?
AC_PRESENT
?
AC_PRESENT
:
AC_ABSENT
;
:
AC_ABSENT
;
/* Get the percentage remaining */
/* Get the percentage remaining */
double
current
;
double
current
;
double
max
;
double
max
;
CFNumberGetValue
(
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOPSCurrentCapacityKey
)),
CFNumberGetValue
(
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOPSCurrentCapacityKey
)),
kCFNumberDoubleType
,
&
current
);
kCFNumberDoubleType
,
&
current
);
CFNumberGetValue
(
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOPSMaxCapacityKey
)),
CFNumberGetValue
(
CFDictionaryGetValue
(
battery
,
CFSTR
(
kIOPSMaxCapacityKey
)),
kCFNumberDoubleType
,
&
max
);
kCFNumberDoubleType
,
&
max
);
*
level
=
(
current
*
100
.
0
)
/
max
;
*
level
=
(
current
*
100
.
0
)
/
max
;
CFRelease
(
battery
);
CFRelease
(
battery
);
}
}
CFRelease
(
list
);
CFRelease
(
list
);
...
...
darwin/DarwinCRT.c
View file @
f70649a1
...
@@ -12,24 +12,24 @@ in the source distribution for its full text.
...
@@ -12,24 +12,24 @@ in the source distribution for its full text.
#include <execinfo.h>
#include <execinfo.h>
void
CRT_handleSIGSEGV
(
int
sgn
)
{
void
CRT_handleSIGSEGV
(
int
sgn
)
{
(
void
)
sgn
;
(
void
)
sgn
;
CRT_done
();
CRT_done
();
#ifdef __APPLE__
#ifdef __APPLE__
fprintf
(
stderr
,
"
\n\n
htop "
VERSION
" aborting. Please report bug at http://hisham.hm/htop
\n
"
);
fprintf
(
stderr
,
"
\n\n
htop "
VERSION
" aborting. Please report bug at http://hisham.hm/htop
\n
"
);
#ifdef HAVE_EXECINFO_H
#ifdef HAVE_EXECINFO_H
size_t
size
=
backtrace
(
backtraceArray
,
sizeof
(
backtraceArray
)
/
sizeof
(
void
*
));
size_t
size
=
backtrace
(
backtraceArray
,
sizeof
(
backtraceArray
)
/
sizeof
(
void
*
));
fprintf
(
stderr
,
"
\n
Please include in your report the following backtrace:
\n
"
);
fprintf
(
stderr
,
"
\n
Please include in your report the following backtrace:
\n
"
);
backtrace_symbols_fd
(
backtraceArray
,
size
,
2
);
backtrace_symbols_fd
(
backtraceArray
,
size
,
2
);
fprintf
(
stderr
,
"
\n
Additionally, in order to make the above backtrace useful,"
);
fprintf
(
stderr
,
"
\n
Additionally, in order to make the above backtrace useful,"
);
fprintf
(
stderr
,
"
\n
please also run the following command to generate a disassembly of your binary:"
);
fprintf
(
stderr
,
"
\n
please also run the following command to generate a disassembly of your binary:"
);
fprintf
(
stderr
,
"
\n\n
otool -tvV `which htop` > ~/htop.otool"
);
fprintf
(
stderr
,
"
\n\n
otool -tvV `which htop` > ~/htop.otool"
);
fprintf
(
stderr
,
"
\n\n
and then attach the file ~/htop.otool to your bug report."
);
fprintf
(
stderr
,
"
\n\n
and then attach the file ~/htop.otool to your bug report."
);
fprintf
(
stderr
,
"
\n\n
Thank you for helping to improve htop!
\n\n
"
);
fprintf
(
stderr
,
"
\n\n
Thank you for helping to improve htop!
\n\n
"
);
#endif
#endif
#else
#else
fprintf
(
stderr
,
"
\n
Unfortunately, you seem to be using an unsupported platform!"
);
fprintf
(
stderr
,
"
\n
Unfortunately, you seem to be using an unsupported platform!"
);
fprintf
(
stderr
,
"
\n
Please contact your platform package mantainer!
\n\n
"
);
fprintf
(
stderr
,
"
\n
Please contact your platform package mantainer!
\n\n
"
);
#endif
#endif
abort
();
abort
();
}
}
darwin/DarwinProcess.c
View file @
f70649a1
...
@@ -62,11 +62,11 @@ bool Process_isThread(Process* this) {
...
@@ -62,11 +62,11 @@ bool Process_isThread(Process* this) {
}
}
void
DarwinProcess_setStartTime
(
Process
*
proc
,
struct
extern_proc
*
ep
,
time_t
now
)
{
void
DarwinProcess_setStartTime
(
Process
*
proc
,
struct
extern_proc
*
ep
,
time_t
now
)
{
struct
tm
date
;
struct
tm
date
;
proc
->
starttime_ctime
=
ep
->
p_starttime
.
tv_sec
;
proc
->
starttime_ctime
=
ep
->
p_starttime
.
tv_sec
;
(
void
)
localtime_r
(
&
proc
->
starttime_ctime
,
&
date
);
(
void
)
localtime_r
(
&
proc
->
starttime_ctime
,
&
date
);
strftime
(
proc
->
starttime_show
,
7
,
((
proc
->
starttime_ctime
>
now
-
86400
)
?
"%R "
:
"%b%d "
),
&
date
);
strftime
(
proc
->
starttime_show
,
7
,
((
proc
->
starttime_ctime
>
now
-
86400
)
?
"%R "
:
"%b%d "
),
&
date
);
}
}
char
*
DarwinProcess_getCmdLine
(
struct
kinfo_proc
*
k
,
int
show_args
)
{
char
*
DarwinProcess_getCmdLine
(
struct
kinfo_proc
*
k
,
int
show_args
)
{
...
@@ -253,92 +253,92 @@ ERROR_A:
...
@@ -253,92 +253,92 @@ ERROR_A:
}
}
void
DarwinProcess_setFromKInfoProc
(
Process
*
proc
,
struct
kinfo_proc
*
ps
,
time_t
now
,
bool
exists
)
{
void
DarwinProcess_setFromKInfoProc
(
Process
*
proc
,
struct
kinfo_proc
*
ps
,
time_t
now
,
bool
exists
)
{
struct
extern_proc
*
ep
=
&
ps
->
kp_proc
;
struct
extern_proc
*
ep
=
&
ps
->
kp_proc
;
/* UNSET HERE :
/* UNSET HERE :
*
*
* processor
* processor
* user (set at ProcessList level)
* user (set at ProcessList level)
* nlwp
* nlwp
* percent_cpu
* percent_cpu
* percent_mem
* percent_mem
* m_size
* m_size
* m_resident
* m_resident
* minflt
* minflt
* majflt
* majflt
*/
*/
/* First, the "immutable" parts */
/* First, the "immutable" parts */
if
(
!
exists
)
{
if
(
!
exists
)
{
/* Set the PID/PGID/etc. */
/* Set the PID/PGID/etc. */
proc
->
pid
=
ep
->
p_pid
;
proc
->
pid
=
ep
->
p_pid
;
proc
->
ppid
=
ps
->
kp_eproc
.
e_ppid
;
proc
->
ppid
=
ps
->
kp_eproc
.
e_ppid
;
proc
->
pgrp
=
ps
->
kp_eproc
.
e_pgid
;
proc
->
pgrp
=
ps
->
kp_eproc
.
e_pgid
;
proc
->
session
=
0
;
/* TODO Get the session id */
proc
->
session
=
0
;
/* TODO Get the session id */
proc
->
tgid
=
ps
->
kp_eproc
.
e_tpgid
;
proc
->
tgid
=
ps
->
kp_eproc
.
e_tpgid
;
proc
->
st_uid
=
ps
->
kp_eproc
.
e_ucred
.
cr_uid
;
proc
->
st_uid
=
ps
->
kp_eproc
.
e_ucred
.
cr_uid
;
/* e_tdev = (major << 24) | (minor & 0xffffff) */
/* e_tdev = (major << 24) | (minor & 0xffffff) */
/* e_tdev == -1 for "no device" */
/* e_tdev == -1 for "no device" */
proc
->
tty_nr
=
ps
->
kp_eproc
.
e_tdev
&
0xff
;
/* TODO tty_nr is unsigned */
proc
->
tty_nr
=
ps
->
kp_eproc
.
e_tdev
&
0xff
;
/* TODO tty_nr is unsigned */
DarwinProcess_setStartTime
(
proc
,
ep
,
now
);
DarwinProcess_setStartTime
(
proc
,
ep
,
now
);
/* The command is from the old Mac htop */
/* The command is from the old Mac htop */
char
*
slash
;
char
*
slash
;
proc
->
comm
=
DarwinProcess_getCmdLine
(
ps
,
false
);
proc
->
comm
=
DarwinProcess_getCmdLine
(
ps
,
false
);
slash
=
strrchr
(
proc
->
comm
,
'/'
);
slash
=
strrchr
(
proc
->
comm
,
'/'
);
proc
->
basenameOffset
=
(
NULL
!=
slash
)
?
(
slash
-
proc
->
comm
)
:
0
;
proc
->
basenameOffset
=
(
NULL
!=
slash
)
?
(
slash
-
proc
->
comm
)
:
0
;
}
}
/* Mutable information */
/* Mutable information */
proc
->
nice
=
ep
->
p_nice
;
proc
->
nice
=
ep
->
p_nice
;
proc
->
priority
=
ep
->
p_priority
;
proc
->
priority
=
ep
->
p_priority
;
/* Set the state */
/* Set the state */
switch
(
ep
->
p_stat
)
{
switch
(
ep
->
p_stat
)
{
case
SIDL
:
proc
->
state
=
'I'
;
break
;
case
SIDL
:
proc
->
state
=
'I'
;
break
;
case
SRUN
:
proc
->
state
=
'R'
;
break
;
case
SRUN
:
proc
->
state
=
'R'
;
break
;
case
SSLEEP
:
proc
->
state
=
'S'
;
break
;
case
SSLEEP
:
proc
->
state
=
'S'
;
break
;
case
SSTOP
:
proc
->
state
=
'T'
;
break
;
case
SSTOP
:
proc
->
state
=
'T'
;
break
;
case
SZOMB
:
proc
->
state
=
'Z'
;
break
;
case
SZOMB
:
proc
->
state
=
'Z'
;
break
;
default:
proc
->
state
=
'?'
;
break
;
default:
proc
->
state
=
'?'
;
break
;
}
}
/* Make sure the updated flag is set */
/* Make sure the updated flag is set */
proc
->
updated
=
true
;
proc
->
updated
=
true
;
}
}
void
DarwinProcess_setFromLibprocPidinfo
(
DarwinProcess
*
proc
,
DarwinProcessList
*
dpl
)
{
void
DarwinProcess_setFromLibprocPidinfo
(
DarwinProcess
*
proc
,
DarwinProcessList
*
dpl
)
{
struct
proc_taskinfo
pti
;
struct
proc_taskinfo
pti
;
if
(
sizeof
(
pti
)
==
proc_pidinfo
(
proc
->
super
.
pid
,
PROC_PIDTASKINFO
,
0
,
&
pti
,
sizeof
(
pti
)))
{
if
(
sizeof
(
pti
)
==
proc_pidinfo
(
proc
->
super
.
pid
,
PROC_PIDTASKINFO
,
0
,
&
pti
,
sizeof
(
pti
)))
{
if
(
0
!=
proc
->
utime
||
0
!=
proc
->
stime
)
{
if
(
0
!=
proc
->
utime
||
0
!=
proc
->
stime
)
{
uint64_t
diff
=
(
pti
.
pti_total_system
-
proc
->
stime
)
uint64_t
diff
=
(
pti
.
pti_total_system
-
proc
->
stime
)
+
(
pti
.
pti_total_user
-
proc
->
utime
);
+
(
pti
.
pti_total_user
-
proc
->
utime
);
proc
->
super
.
percent_cpu
=
(
double
)
diff
*
(
double
)
dpl
->
super
.
cpuCount
proc
->
super
.
percent_cpu
=
(
double
)
diff
*
(
double
)
dpl
->
super
.
cpuCount
/
((
double
)
dpl
->
global_diff
*
100000
.
0
);
/
((
double
)
dpl
->
global_diff
*
100000
.
0
);
//
fprintf(stderr, "%f %llu %llu %llu %llu %llu\n", proc->super.percent_cpu,
// fprintf(stderr, "%f %llu %llu %llu %llu %llu\n", proc->super.percent_cpu,
//
proc->stime, proc->utime, pti.pti_total_system, pti.pti_total_user, dpl->global_diff);
// proc->stime, proc->utime, pti.pti_total_system, pti.pti_total_user, dpl->global_diff);
//
exit(7);
// exit(7);
}
}
proc
->
super
.
time
=
(
pti
.
pti_total_system
+
pti
.
pti_total_user
)
/
10000000
;
proc
->
super
.
time
=
(
pti
.
pti_total_system
+
pti
.
pti_total_user
)
/
10000000
;
proc
->
super
.
nlwp
=
pti
.
pti_threadnum
;
proc
->
super
.
nlwp
=
pti
.
pti_threadnum
;
proc
->
super
.
m_size
=
pti
.
pti_virtual_size
/
1024
;
proc
->
super
.
m_size
=
pti
.
pti_virtual_size
/
1024
;
proc
->
super
.
m_resident
=
pti
.
pti_resident_size
/
1024
;
proc
->
super
.
m_resident
=
pti
.
pti_resident_size
/
1024
;
proc
->
super
.
majflt
=
pti
.
pti_faults
;
proc
->
super
.
majflt
=
pti
.
pti_faults
;
proc
->
super
.
percent_mem
=
(
double
)
pti
.
pti_resident_size
*
100
.
0
proc
->
super
.
percent_mem
=
(
double
)
pti
.
pti_resident_size
*
100
.
0
/
(
double
)
dpl
->
host_info
.
max_mem
;
/
(
double
)
dpl
->
host_info
.
max_mem
;
proc
->
stime
=
pti
.
pti_total_system
;
proc
->
stime
=
pti
.
pti_total_system
;
proc
->
utime
=
pti
.
pti_total_user
;
proc
->
utime
=
pti
.
pti_total_user
;
dpl
->
super
.
kernelThreads
+=
0
;
/*pti.pti_threads_system;*/
dpl
->
super
.
kernelThreads
+=
0
;
/*pti.pti_threads_system;*/
dpl
->
super
.
userlandThreads
+=
pti
.
pti_threadnum
;
/*pti.pti_threads_user;*/
dpl
->
super
.
userlandThreads
+=
pti
.
pti_threadnum
;
/*pti.pti_threads_user;*/
dpl
->
super
.
totalTasks
+=
pti
.
pti_threadnum
;
dpl
->
super
.
totalTasks
+=
pti
.
pti_threadnum
;
dpl
->
super
.
runningTasks
+=
pti
.
pti_numrunning
;
dpl
->
super
.
runningTasks
+=
pti
.
pti_numrunning
;
}
}
}
}
darwin/Platform.c
View file @
f70649a1
...
@@ -85,17 +85,17 @@ char* Process_pidFormat = "%7u ";
...
@@ -85,17 +85,17 @@ char* Process_pidFormat = "%7u ";
char
*
Process_tpgidFormat
=
"%7u "
;
char
*
Process_tpgidFormat
=
"%7u "
;
int
Platform_getUptime
()
{
int
Platform_getUptime
()
{
struct
timeval
bootTime
,
currTime
;
struct
timeval
bootTime
,
currTime
;
int
mib
[
2
]
=
{
CTL_KERN
,
KERN_BOOTTIME
};
int
mib
[
2
]
=
{
CTL_KERN
,
KERN_BOOTTIME
};
size_t
size
=
sizeof
(
bootTime
);
size_t
size
=
sizeof
(
bootTime
);
int
err
=
sysctl
(
mib
,
2
,
&
bootTime
,
&
size
,
NULL
,
0
);
int
err
=
sysctl
(
mib
,
2
,
&
bootTime
,
&
size
,
NULL
,
0
);
if
(
err
)
{
if
(
err
)
{
return
-
1
;
return
-
1
;
}
}
gettimeofday
(
&
currTime
,
NULL
);
gettimeofday
(
&
currTime
,
NULL
);
return
(
int
)
difftime
(
currTime
.
tv_sec
,
bootTime
.
tv_sec
);
return
(
int
)
difftime
(
currTime
.
tv_sec
,
bootTime
.
tv_sec
);
}
}
void
Platform_getLoadAverage
(
double
*
one
,
double
*
five
,
double
*
fifteen
)
{
void
Platform_getLoadAverage
(
double
*
one
,
double
*
five
,
double
*
fifteen
)
{
...
@@ -142,46 +142,45 @@ void Process_setupColumnWidths() {
...
@@ -142,46 +142,45 @@ void Process_setupColumnWidths() {
}
}
double
Platform_setCPUValues
(
Meter
*
mtr
,
int
cpu
)
{
double
Platform_setCPUValues
(
Meter
*
mtr
,
int
cpu
)
{
/* All just from CPUMeter.c */
/* All just from CPUMeter.c */
static
const
int
CPU_METER_NICE
=
0
;
static
const
int
CPU_METER_NICE
=
0
;
static
const
int
CPU_METER_NORMAL
=
1
;
static
const
int
CPU_METER_NORMAL
=
1
;
static
const
int
CPU_METER_KERNEL
=
2
;
static
const
int
CPU_METER_KERNEL
=
2
;
DarwinProcessList
*
dpl
=
(
DarwinProcessList
*
)
mtr
->
pl
;
DarwinProcessList
*
dpl
=
(
DarwinProcessList
*
)
mtr
->
pl
;
processor_cpu_load_info_t
prev
=
&
dpl
->
prev_load
[
cpu
-
1
];
processor_cpu_load_info_t
prev
=
&
dpl
->
prev_load
[
cpu
-
1
];
processor_cpu_load_info_t
curr
=
&
dpl
->
curr_load
[
cpu
-
1
];
processor_cpu_load_info_t
curr
=
&
dpl
->
curr_load
[
cpu
-
1
];
double
total
=
0
;
double
total
=
0
;
/* Take the sums */
/* Take the sums */
for
(
size_t
i
=
0
;
i
<
CPU_STATE_MAX
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
CPU_STATE_MAX
;
++
i
)
{
total
+=
(
double
)
curr
->
cpu_ticks
[
i
]
-
(
double
)
prev
->
cpu_ticks
[
i
];
total
+=
(
double
)
curr
->
cpu_ticks
[
i
]
-
(
double
)
prev
->
cpu_ticks
[
i
];
}
}
mtr
->
values
[
CPU_METER_NICE
]
=
((
double
)
curr
->
cpu_ticks
[
CPU_STATE_NICE
]
-
(
double
)
prev
->
cpu_ticks
[
CPU_STATE_NICE
])
*
100
.
0
/
total
;
mtr
->
values
[
CPU_METER_NORMAL
]
=
((
double
)
curr
->
cpu_ticks
[
CPU_STATE_USER
]
-
(
double
)
prev
->
cpu_ticks
[
CPU_STATE_USER
])
*
100
.
0
/
total
;
mtr
->
values
[
CPU_METER_KERNEL
]
=
((
double
)
curr
->
cpu_ticks
[
CPU_STATE_SYSTEM
]
-
(
double
)
prev
->
cpu_ticks
[
CPU_STATE_SYSTEM
])
*
100
.
0
/
total
;
Meter_setItems
(
mtr
,
3
);
/* Convert to percent and return */
total
=
mtr
->
values
[
CPU_METER_NICE
]
+
mtr
->
values
[
CPU_METER_NORMAL
]
+
mtr
->
values
[
CPU_METER_KERNEL
];
return
MIN
(
100
.
0
,
MAX
(
0
.
0
,
total
));
}
void
Platform_setMemoryValues
(
Meter
*
mtr
)
{
mtr
->
values
[
CPU_METER_NICE
]
DarwinProcessList
*
dpl
=
(
DarwinProcessList
*
)
mtr
->
pl
;
=
((
double
)
curr
->
cpu_ticks
[
CPU_STATE_NICE
]
-
(
double
)
prev
->
cpu_ticks
[
CPU_STATE_NICE
])
*
100
.
0
/
total
;
vm_statistics64_t
vm
=
&
dpl
->
vm_stats
;
mtr
->
values
[
CPU_METER_NORMAL
]
double
page_K
=
(
double
)
vm_page_size
/
(
double
)
1024
;
=
((
double
)
curr
->
cpu_ticks
[
CPU_STATE_USER
]
-
(
double
)
prev
->
cpu_ticks
[
CPU_STATE_USER
])
*
100
.
0
/
total
;
mtr
->
values
[
CPU_METER_KERNEL
]
=
((
double
)
curr
->
cpu_ticks
[
CPU_STATE_SYSTEM
]
-
(
double
)
prev
->
cpu_ticks
[
CPU_STATE_SYSTEM
])
*
100
.
0
/
total
;
mtr
->
total
=
dpl
->
host_info
.
max_mem
/
1024
;
Meter_setItems
(
mtr
,
3
);
mtr
->
values
[
0
]
=
(
double
)(
vm
->
active_count
+
vm
->
wire_count
)
*
page_K
;
mtr
->
values
[
1
]
=
(
double
)
vm
->
purgeable_count
*
page_K
;
mtr
->
values
[
2
]
=
(
double
)
vm
->
inactive_count
*
page_K
;
/* Convert to percent and return */
total
=
mtr
->
values
[
CPU_METER_NICE
]
+
mtr
->
values
[
CPU_METER_NORMAL
]
+
mtr
->
values
[
CPU_METER_KERNEL
];
return
MIN
(
100
.
0
,
MAX
(
0
.
0
,
total
));
}
void
Platform_setMemoryValues
(
Meter
*
mtr
)
{
DarwinProcessList
*
dpl
=
(
DarwinProcessList
*
)
mtr
->
pl
;
vm_statistics64_t
vm
=
&
dpl
->
vm_stats
;
double
page_K
=
(
double
)
vm_page_size
/
(
double
)
1024
;
mtr
->
total
=
dpl
->
host_info
.
max_mem
/
1024
;
mtr
->
values
[
0
]
=
(
double
)(
vm
->
active_count
+
vm
->
wire_count
)
*
page_K
;
mtr
->
values
[
1
]
=
(
double
)
vm
->
purgeable_count
*
page_K
;
mtr
->
values
[
2
]
=
(
double
)
vm
->
inactive_count
*
page_K
;
}
}
void
Platform_setSwapValues
(
Meter
*
this
)
{
void
Platform_setSwapValues
(
Meter
*
this
)
{
...
...
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