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
4ba06c51
Commit
4ba06c51
authored
Mar 27, 2018
by
Guy M. Broome
Committed by
Hisham Muhammad
Apr 05, 2018
Browse files
Solaris: Condense conditional blocks for new vs old LWPs and procs
parent
fa18ac96
Changes
1
Show whitespace changes
Inline
Side-by-side
solaris/SolarisProcessList.c
View file @
4ba06c51
...
@@ -278,32 +278,18 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
...
@@ -278,32 +278,18 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
fread
(
&
_lwprusage
,
sizeof
(
prusage_t
),
1
,
fp
);
fread
(
&
_lwprusage
,
sizeof
(
prusage_t
),
1
,
fp
);
fclose
(
fp
);
fclose
(
fp
);
}
}
slwp
->
is_lwp
=
true
;
if
(
!
preExisting
)
{
// Common items set for both new and refreshed LWPs
lwp
->
basenameOffset
=
-
1
;
slwp
->
kernel
=
sproc
->
kernel
;
// Fake values used for sorting
lwp
->
pid
=
lwpid
;
lwp
->
ppid
=
proc
->
pid
;
lwp
->
tgid
=
proc
->
pid
;
// Corresponding real values used for display
slwp
->
realpid
=
sproc
->
realpid
;
slwp
->
realppid
=
sproc
->
realpid
;
slwp
->
lwpid
=
atoi
(
lwpname
);
slwp
->
zoneid
=
sproc
->
zoneid
;
slwp
->
zoneid
=
sproc
->
zoneid
;
lwp
->
tty_nr
=
proc
->
tty_nr
;
lwp
->
pgrp
=
proc
->
pgrp
;
lwp
->
percent_cpu
=
((
uint16_t
)
_lwpsinfo
.
pr_pctcpu
/
(
double
)
32768
)
*
(
double
)
100
.
0
;
lwp
->
percent_cpu
=
((
uint16_t
)
_lwpsinfo
.
pr_pctcpu
/
(
double
)
32768
)
*
(
double
)
100
.
0
;
// Not tracked per thread
lwp
->
pgrp
=
proc
->
pgrp
;
lwp
->
percent_mem
=
(
double
)
0
.
0
;
lwp
->
st_uid
=
proc
->
st_uid
;
lwp
->
st_uid
=
proc
->
st_uid
;
lwp
->
user
=
UsersTable_getRef
(
pl
->
usersTable
,
lwp
->
st_uid
);
lwp
->
user
=
UsersTable_getRef
(
pl
->
usersTable
,
lwp
->
st_uid
);
lwp
->
nlwp
=
0
;
lwp
->
session
=
proc
->
session
;
lwp
->
session
=
proc
->
session
;
lwp
->
comm
=
xStrdup
(
proc
->
comm
);
lwp
->
comm
=
xStrdup
(
proc
->
comm
);
lwp
->
commLen
=
strnlen
(
proc
->
comm
,
PRFNSZ
);
lwp
->
commLen
=
strnlen
(
proc
->
comm
,
PRFNSZ
);
slwp
->
zname
=
sproc
->
zname
;
slwp
->
zname
=
sproc
->
zname
;
lwp
->
tty_nr
=
proc
->
tty_nr
;
if
(
haveUsage
)
{
if
(
haveUsage
)
{
lwp
->
majflt
=
_lwprusage
.
pr_majf
;
lwp
->
majflt
=
_lwprusage
.
pr_majf
;
lwp
->
minflt
=
_lwprusage
.
pr_minf
;
lwp
->
minflt
=
_lwprusage
.
pr_minf
;
...
@@ -311,8 +297,6 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
...
@@ -311,8 +297,6 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
lwp
->
majflt
=
0
;
lwp
->
majflt
=
0
;
lwp
->
minflt
=
0
;
lwp
->
minflt
=
0
;
}
}
lwp
->
m_resident
=
0
;
lwp
->
m_size
=
0
;
lwp
->
priority
=
_lwpsinfo
.
pr_pri
;
lwp
->
priority
=
_lwpsinfo
.
pr_pri
;
lwp
->
nice
=
_lwpsinfo
.
pr_nice
;
lwp
->
nice
=
_lwpsinfo
.
pr_nice
;
lwp
->
processor
=
_lwpsinfo
.
pr_onpro
;
lwp
->
processor
=
_lwpsinfo
.
pr_onpro
;
...
@@ -322,48 +306,44 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
...
@@ -322,48 +306,44 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
slwp
->
projid
=
sproc
->
projid
;
slwp
->
projid
=
sproc
->
projid
;
slwp
->
poolid
=
sproc
->
poolid
;
slwp
->
poolid
=
sproc
->
poolid
;
slwp
->
contid
=
sproc
->
contid
;
slwp
->
contid
=
sproc
->
contid
;
lwp
->
starttime_ctime
=
_lwpsinfo
.
pr_start
.
tv_sec
;
(
void
)
localtime_r
((
time_t
*
)
&
lwp
->
starttime_ctime
,
&
date
);
strftime
(
lwp
->
starttime_show
,
7
,
((
lwp
->
starttime_ctime
>
tv
.
tv_sec
-
86400
)
?
"%R "
:
"%b%d "
),
&
date
);
ProcessList_add
(
pl
,
lwp
);
lwp
->
show
=
false
;
lwp
->
show
=
false
;
}
else
{
slwp
->
zoneid
=
sproc
->
zoneid
;
// Tasks done only for NEW LWPs
lwp
->
pgrp
=
proc
->
pgrp
;
if
(
!
preExisting
)
{
lwp
->
percent_cpu
=
((
uint16_t
)
_lwpsinfo
.
pr_pctcpu
/
(
double
)
32768
)
*
(
double
)
100
.
0
;
slwp
->
is_lwp
=
true
;
lwp
->
basenameOffset
=
-
1
;
slwp
->
kernel
=
sproc
->
kernel
;
// Fake values used for sorting
// Only set once because threads don't generally
// move... between... processes.
lwp
->
pid
=
lwpid
;
lwp
->
ppid
=
proc
->
pid
;
lwp
->
tgid
=
proc
->
pid
;
// Corresponding real values used for display
slwp
->
realpid
=
sproc
->
realpid
;
slwp
->
realppid
=
sproc
->
realpid
;
slwp
->
lwpid
=
atoi
(
lwpname
);
// Not tracked per thread
// Not tracked per thread
lwp
->
percent_mem
=
(
double
)
0
.
0
;
lwp
->
percent_mem
=
(
double
)
0
.
0
;
lwp
->
st_uid
=
proc
->
st_uid
;
lwp
->
user
=
UsersTable_getRef
(
pl
->
usersTable
,
lwp
->
st_uid
);
lwp
->
nlwp
=
0
;
lwp
->
nlwp
=
0
;
lwp
->
session
=
proc
->
session
;
lwp
->
comm
=
xStrdup
(
proc
->
comm
);
lwp
->
commLen
=
strnlen
(
proc
->
comm
,
PRFNSZ
);
slwp
->
zname
=
sproc
->
zname
;
if
(
haveUsage
)
{
lwp
->
majflt
=
_lwprusage
.
pr_majf
;
lwp
->
minflt
=
_lwprusage
.
pr_minf
;
}
lwp
->
m_resident
=
0
;
lwp
->
m_resident
=
0
;
lwp
->
m_size
=
0
;
lwp
->
m_size
=
0
;
lwp
->
priority
=
_lwpsinfo
.
pr_pri
;
lwp
->
starttime_ctime
=
_lwpsinfo
.
pr_start
.
tv_sec
;
lwp
->
nice
=
_lwpsinfo
.
pr_nice
;
(
void
)
localtime_r
((
time_t
*
)
&
lwp
->
starttime_ctime
,
&
date
);
lwp
->
processor
=
_lwpsinfo
.
pr_onpro
;
strftime
(
lwp
->
starttime_show
,
7
,
((
lwp
->
starttime_ctime
>
tv
.
tv_sec
-
86400
)
?
"%R "
:
"%b%d "
),
&
date
);
lwp
->
state
=
_lwpsinfo
.
pr_sname
;
ProcessList_add
(
pl
,
lwp
);
lwp
->
time
=
_lwpsinfo
.
pr_time
.
tv_sec
;
slwp
->
taskid
=
sproc
->
taskid
;
slwp
->
projid
=
sproc
->
projid
;
slwp
->
poolid
=
sproc
->
poolid
;
slwp
->
contid
=
sproc
->
contid
;
lwp
->
show
=
false
;
}
}
// Top-level process only gets this for the representative LWP
// Top-level process only gets this for the representative LWP
if
(
lwp
->
state
==
'O'
)
proc
->
state
=
'O'
;
if
(
lwp
->
state
==
'O'
)
proc
->
state
=
'O'
;
if
(
slwp
->
kernel
&&
!
pl
->
settings
->
hideKernelThreads
)
lwp
->
show
=
true
;
if
(
slwp
->
kernel
&&
!
pl
->
settings
->
hideKernelThreads
)
lwp
->
show
=
true
;
if
(
!
slwp
->
kernel
&&
!
pl
->
settings
->
hideUserlandThreads
)
lwp
->
show
=
true
;
if
(
!
slwp
->
kernel
&&
!
pl
->
settings
->
hideUserlandThreads
)
lwp
->
show
=
true
;
lwp
->
updated
=
true
;
lwp
->
updated
=
true
;
}
}
closedir
(
dir
);
closedir
(
dir
);
}
}
...
@@ -415,20 +395,13 @@ void ProcessList_goThroughEntries(ProcessList* this) {
...
@@ -415,20 +395,13 @@ void ProcessList_goThroughEntries(ProcessList* this) {
if
(
fp
==
NULL
)
continue
;
if
(
fp
==
NULL
)
continue
;
fread
(
&
_prusage
,
sizeof
(
prusage_t
),
1
,
fp
);
fread
(
&
_prusage
,
sizeof
(
prusage_t
),
1
,
fp
);
fclose
(
fp
);
fclose
(
fp
);
sproc
->
is_lwp
=
FALSE
;
if
(
!
preExisting
)
{
// Common items set for both new and refreshed processes
// Fake PID values used for sorting, since Solaris LWPs lack unique PIDs
proc
->
pid
=
(
_psinfo
.
pr_pid
*
1024
);
proc
->
ppid
=
(
_psinfo
.
pr_ppid
*
1024
);
proc
->
ppid
=
(
_psinfo
.
pr_ppid
*
1024
);
proc
->
tgid
=
(
_psinfo
.
pr_ppid
*
1024
);
proc
->
tgid
=
(
_psinfo
.
pr_ppid
*
1024
);
// Corresponding real values used for display
sproc
->
realpid
=
_psinfo
.
pr_pid
;
sproc
->
realppid
=
_psinfo
.
pr_ppid
;
sproc
->
realppid
=
_psinfo
.
pr_ppid
;
sproc
->
lwpid
=
0
;
sproc
->
zoneid
=
_psinfo
.
pr_zoneid
;
sproc
->
zoneid
=
_psinfo
.
pr_zoneid
;
proc
->
tty_nr
=
_psinfo
.
pr_ttydev
;
sproc
->
zname
=
SolarisProcessList_readZoneName
(
spl
->
kd
,
sproc
);
proc
->
pgrp
=
_psinfo
.
pr_pgid
;
// NOTE: These 'percentages' are 16-bit BINARY FRACTIONS where 1.0 = 0x8000
// NOTE: These 'percentages' are 16-bit BINARY FRACTIONS where 1.0 = 0x8000
// Source: https://docs.oracle.com/cd/E19253-01/816-5174/proc-4/index.html
// Source: https://docs.oracle.com/cd/E19253-01/816-5174/proc-4/index.html
// (accessed on 18 November 2017)
// (accessed on 18 November 2017)
...
@@ -436,11 +409,12 @@ void ProcessList_goThroughEntries(ProcessList* this) {
...
@@ -436,11 +409,12 @@ void ProcessList_goThroughEntries(ProcessList* this) {
proc
->
percent_mem
=
((
uint16_t
)
_psinfo
.
pr_pctmem
/
(
double
)
32768
)
*
(
double
)
100
.
0
;
proc
->
percent_mem
=
((
uint16_t
)
_psinfo
.
pr_pctmem
/
(
double
)
32768
)
*
(
double
)
100
.
0
;
proc
->
st_uid
=
_psinfo
.
pr_euid
;
proc
->
st_uid
=
_psinfo
.
pr_euid
;
proc
->
user
=
UsersTable_getRef
(
this
->
usersTable
,
proc
->
st_uid
);
proc
->
user
=
UsersTable_getRef
(
this
->
usersTable
,
proc
->
st_uid
);
proc
->
pgrp
=
_psinfo
.
pr_pgid
;
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
session
=
_pstatus
.
pr_sid
;
proc
->
session
=
_pstatus
.
pr_sid
;
proc
->
comm
=
xStrdup
(
_psinfo
.
pr_fname
);
proc
->
comm
=
xStrdup
(
_psinfo
.
pr_fname
);
proc
->
commLen
=
strnlen
(
_psinfo
.
pr_fname
,
PRFNSZ
);
proc
->
commLen
=
strnlen
(
_psinfo
.
pr_fname
,
PRFNSZ
);
s
proc
->
zname
=
SolarisProcessList_readZoneName
(
spl
->
kd
,
sproc
)
;
proc
->
tty_nr
=
_psinfo
.
pr_ttydev
;
proc
->
majflt
=
_prusage
.
pr_majf
;
proc
->
majflt
=
_prusage
.
pr_majf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
m_resident
=
_psinfo
.
pr_rssize
/
PAGE_SIZE_KB
;
proc
->
m_resident
=
_psinfo
.
pr_rssize
/
PAGE_SIZE_KB
;
...
@@ -454,6 +428,15 @@ void ProcessList_goThroughEntries(ProcessList* this) {
...
@@ -454,6 +428,15 @@ void ProcessList_goThroughEntries(ProcessList* this) {
sproc
->
projid
=
_psinfo
.
pr_projid
;
sproc
->
projid
=
_psinfo
.
pr_projid
;
sproc
->
poolid
=
_psinfo
.
pr_poolid
;
sproc
->
poolid
=
_psinfo
.
pr_poolid
;
sproc
->
contid
=
_psinfo
.
pr_contract
;
sproc
->
contid
=
_psinfo
.
pr_contract
;
// Tasks done only for NEW processes
if
(
!
preExisting
)
{
sproc
->
is_lwp
=
false
;
// Fake PID values used for sorting, since Solaris LWPs lack unique PIDs
proc
->
pid
=
(
_psinfo
.
pr_pid
*
1024
);
// Corresponding real values used for display
sproc
->
realpid
=
_psinfo
.
pr_pid
;
sproc
->
lwpid
=
0
;
proc
->
starttime_ctime
=
_psinfo
.
pr_start
.
tv_sec
;
proc
->
starttime_ctime
=
_psinfo
.
pr_start
.
tv_sec
;
if
((
sproc
->
realppid
<=
0
)
&&
!
(
sproc
->
realpid
<=
1
))
{
if
((
sproc
->
realppid
<=
0
)
&&
!
(
sproc
->
realpid
<=
1
))
{
sproc
->
kernel
=
true
;
sproc
->
kernel
=
true
;
...
@@ -463,35 +446,6 @@ void ProcessList_goThroughEntries(ProcessList* this) {
...
@@ -463,35 +446,6 @@ void ProcessList_goThroughEntries(ProcessList* this) {
(
void
)
localtime_r
((
time_t
*
)
&
proc
->
starttime_ctime
,
&
date
);
(
void
)
localtime_r
((
time_t
*
)
&
proc
->
starttime_ctime
,
&
date
);
strftime
(
proc
->
starttime_show
,
7
,
((
proc
->
starttime_ctime
>
tv
.
tv_sec
-
86400
)
?
"%R "
:
"%b%d "
),
&
date
);
strftime
(
proc
->
starttime_show
,
7
,
((
proc
->
starttime_ctime
>
tv
.
tv_sec
-
86400
)
?
"%R "
:
"%b%d "
),
&
date
);
ProcessList_add
(
this
,
proc
);
ProcessList_add
(
this
,
proc
);
}
else
{
proc
->
ppid
=
(
_psinfo
.
pr_ppid
*
1024
);
proc
->
tgid
=
(
_psinfo
.
pr_ppid
*
1024
);
sproc
->
realppid
=
_psinfo
.
pr_ppid
;
sproc
->
lwpid
=
0
;
sproc
->
zoneid
=
_psinfo
.
pr_zoneid
;
// See note above about these percentages
proc
->
percent_cpu
=
((
uint16_t
)
_psinfo
.
pr_pctcpu
/
(
double
)
32768
)
*
(
double
)
100
.
0
;
proc
->
percent_mem
=
((
uint16_t
)
_psinfo
.
pr_pctmem
/
(
double
)
32768
)
*
(
double
)
100
.
0
;
proc
->
st_uid
=
_psinfo
.
pr_euid
;
proc
->
pgrp
=
_psinfo
.
pr_pgid
;
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
user
=
UsersTable_getRef
(
this
->
usersTable
,
proc
->
st_uid
);
proc
->
comm
=
xStrdup
(
_psinfo
.
pr_fname
);
proc
->
commLen
=
strnlen
(
_psinfo
.
pr_fname
,
PRFNSZ
);
sproc
->
zname
=
SolarisProcessList_readZoneName
(
spl
->
kd
,
sproc
);
proc
->
majflt
=
_prusage
.
pr_majf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
m_resident
=
_psinfo
.
pr_rssize
/
PAGE_SIZE_KB
;
proc
->
m_size
=
_psinfo
.
pr_size
/
PAGE_SIZE_KB
;
proc
->
priority
=
_psinfo
.
pr_lwp
.
pr_pri
;
proc
->
nice
=
_psinfo
.
pr_lwp
.
pr_nice
;
proc
->
processor
=
_psinfo
.
pr_lwp
.
pr_onpro
;
proc
->
state
=
_psinfo
.
pr_lwp
.
pr_sname
;
proc
->
time
=
_psinfo
.
pr_time
.
tv_sec
;
sproc
->
taskid
=
_psinfo
.
pr_taskid
;
sproc
->
projid
=
_psinfo
.
pr_projid
;
sproc
->
poolid
=
_psinfo
.
pr_poolid
;
sproc
->
contid
=
_psinfo
.
pr_contract
;
}
}
if
(
proc
->
nlwp
>
1
)
{
if
(
proc
->
nlwp
>
1
)
{
...
...
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