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
831538b0
Commit
831538b0
authored
Nov 23, 2010
by
Hisham Muhammad
Browse files
Split process and thread counts in tasks meter
parent
d8e1480a
Changes
5
Hide whitespace changes
Inline
Side-by-side
CRT.c
View file @
831538b0
...
...
@@ -58,7 +58,6 @@ typedef enum ColorElements_ {
LED_COLOR,
UPTIME,
BATTERY,
TASKS_TOTAL,
TASKS_RUNNING,
SWAP,
PROCESS,
...
...
CRT.h
View file @
831538b0
...
...
@@ -60,7 +60,6 @@ typedef enum ColorElements_ {
LED_COLOR
,
UPTIME
,
BATTERY
,
TASKS_TOTAL
,
TASKS_RUNNING
,
SWAP
,
PROCESS
,
...
...
ProcessList.c
View file @
831538b0
...
...
@@ -94,6 +94,8 @@ typedef struct ProcessList_ {
int cpuCount;
int totalTasks;
int userlandThreads;
int kernelThreads;
int runningTasks;
CPUData* cpus;
...
...
@@ -635,6 +637,11 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
if
(
!
ProcessList_readCmdlineFile
(
process
,
dirname
,
name
))
goto
errorReadingProcess
;
}
if
(
Process_isKernelThread
(
process
))
{
this
->
kernelThreads
++
;
}
else
{
this
->
userlandThreads
++
;
}
}
this
->
totalTasks
++
;
...
...
@@ -772,6 +779,8 @@ void ProcessList_scan(ProcessList* this) {
}
this
->
totalTasks
=
0
;
this
->
userlandThreads
=
0
;
this
->
kernelThreads
=
0
;
this
->
runningTasks
=
0
;
ProcessList_processEntries
(
this
,
PROCDIR
,
NULL
,
period
);
...
...
ProcessList.h
View file @
831538b0
...
...
@@ -94,6 +94,8 @@ typedef struct ProcessList_ {
int
cpuCount
;
int
totalTasks
;
int
userlandThreads
;
int
kernelThreads
;
int
runningTasks
;
CPUData
*
cpus
;
...
...
TasksMeter.c
View file @
831538b0
...
...
@@ -19,17 +19,37 @@ int TasksMeter_attributes[] = {
};
static
void
TasksMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
this
->
total
=
this
->
pl
->
totalTasks
;
this
->
values
[
0
]
=
this
->
pl
->
runningTasks
;
ProcessList
*
pl
=
this
->
pl
;
this
->
total
=
pl
->
totalTasks
;
this
->
values
[
0
]
=
pl
->
runningTasks
;
snprintf
(
buffer
,
len
,
"%d/%d"
,
(
int
)
this
->
values
[
0
],
(
int
)
this
->
total
);
}
static
void
TasksMeter_display
(
Object
*
cast
,
RichString
*
out
)
{
Meter
*
this
=
(
Meter
*
)
cast
;
ProcessList
*
pl
=
this
->
pl
;
char
buffer
[
20
];
sprintf
(
buffer
,
"%d"
,
(
int
)
this
->
total
);
sprintf
(
buffer
,
"%d"
,
(
int
)
(
this
->
total
-
pl
->
userlandThreads
-
pl
->
kernelThreads
)
);
RichString_write
(
out
,
CRT_colors
[
METER_VALUE
],
buffer
);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
" total, "
);
int
threadValueColor
=
CRT_colors
[
METER_VALUE
];
int
threadCaptionColor
=
CRT_colors
[
METER_TEXT
];
if
(
pl
->
highlightThreads
)
{
threadValueColor
=
CRT_colors
[
PROCESS_THREAD_BASENAME
];
threadCaptionColor
=
CRT_colors
[
PROCESS_THREAD
];
}
if
(
!
pl
->
hideUserlandThreads
)
{
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
", "
);
sprintf
(
buffer
,
"%d"
,
(
int
)
pl
->
userlandThreads
);
RichString_append
(
out
,
threadValueColor
,
buffer
);
RichString_append
(
out
,
threadCaptionColor
,
" thr"
);
}
if
(
!
pl
->
hideKernelThreads
)
{
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
", "
);
sprintf
(
buffer
,
"%d"
,
(
int
)
pl
->
kernelThreads
);
RichString_append
(
out
,
threadValueColor
,
buffer
);
RichString_append
(
out
,
threadCaptionColor
,
" kthr"
);
}
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"; "
);
sprintf
(
buffer
,
"%d"
,
(
int
)
this
->
values
[
0
]);
RichString_append
(
out
,
CRT_colors
[
TASKS_RUNNING
],
buffer
);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
" running"
);
...
...
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