summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-17 14:48:55 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-17 23:16:14 +0200
commitc02c6fef285863427ae0c3c278e3f48fb5ae381f (patch)
treead9cb771ecbd86652a2a65f866320c2f03687797 /Applications
parentc59f8cd66388f789668d083d2c43226a50b71c08 (diff)
downloadserenity-c02c6fef285863427ae0c3c278e3f48fb5ae381f.zip
Kernel+ProcessManager: Show per-process syscall counts.
Added a simple syscall counter to the /proc/all contents. :^)
Diffstat (limited to 'Applications')
-rw-r--r--Applications/ProcessManager/ProcessModel.cpp10
-rw-r--r--Applications/ProcessManager/ProcessModel.h2
-rw-r--r--Applications/ProcessManager/main.cpp2
3 files changed, 12 insertions, 2 deletions
diff --git a/Applications/ProcessManager/ProcessModel.cpp b/Applications/ProcessManager/ProcessModel.cpp
index c83bb2c2f2..fdf0a1e13b 100644
--- a/Applications/ProcessManager/ProcessModel.cpp
+++ b/Applications/ProcessManager/ProcessModel.cpp
@@ -43,6 +43,7 @@ String ProcessModel::column_name(int column) const
case Column::Physical: return "Physical";
case Column::CPU: return "CPU";
case Column::Name: return "Name";
+ case Column::Syscalls: return "Syscalls";
default: ASSERT_NOT_REACHED();
}
}
@@ -59,6 +60,7 @@ GModel::ColumnMetadata ProcessModel::column_metadata(int column) const
case Column::Physical: return { 65, TextAlignment::CenterRight };
case Column::CPU: return { 25, TextAlignment::CenterRight };
case Column::Name: return { 140, TextAlignment::CenterLeft };
+ case Column::Syscalls: return { 60, TextAlignment::CenterRight };
default: ASSERT_NOT_REACHED();
}
}
@@ -94,6 +96,8 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
case Column::Physical: return (int)process.current_state.physical;
case Column::CPU: return process.current_state.cpu_percent;
case Column::Name: return process.current_state.name;
+ // FIXME: GVariant with unsigned?
+ case Column::Syscalls: return (int)process.current_state.syscalls;
}
ASSERT_NOT_REACHED();
return { };
@@ -117,6 +121,8 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
case Column::Physical: return pretty_byte_size(process.current_state.physical);
case Column::CPU: return process.current_state.cpu_percent;
case Column::Name: return process.current_state.name;
+ // FIXME: It's weird that GVariant doesn't support unsigned ints. Should it?
+ case Column::Syscalls: return (int)process.current_state.syscalls;
}
}
@@ -143,7 +149,7 @@ void ProcessModel::update()
if (line.is_empty())
break;
auto parts = String((const char*)line.pointer(), line.size() - 1, Chomp).split(',');
- if (parts.size() < 17)
+ if (parts.size() < 18)
break;
bool ok;
pid_t pid = parts[0].to_uint(ok);
@@ -163,6 +169,8 @@ void ProcessModel::update()
state.user = String::format("%u", uid);
}
state.priority = parts[16];
+ state.syscalls = parts[17].to_uint(ok);
+ ASSERT(ok);
state.state = parts[7];
state.name = parts[11];
state.linear = parts[12].to_uint(ok);
diff --git a/Applications/ProcessManager/ProcessModel.h b/Applications/ProcessManager/ProcessModel.h
index 849ee8f03b..f012cb75ee 100644
--- a/Applications/ProcessManager/ProcessModel.h
+++ b/Applications/ProcessManager/ProcessModel.h
@@ -18,6 +18,7 @@ public:
PID,
Linear,
Physical,
+ Syscalls,
__Count
};
@@ -43,6 +44,7 @@ private:
String priority;
size_t linear;
size_t physical;
+ unsigned syscalls;
float cpu_percent;
};
diff --git a/Applications/ProcessManager/main.cpp b/Applications/ProcessManager/main.cpp
index ba15049662..f10126bcff 100644
--- a/Applications/ProcessManager/main.cpp
+++ b/Applications/ProcessManager/main.cpp
@@ -69,7 +69,7 @@ int main(int argc, char** argv)
auto* window = new GWindow;
window->set_title("ProcessManager");
- window->set_rect(20, 200, 640, 400);
+ window->set_rect(20, 200, 680, 400);
window->set_main_widget(widget);
window->set_should_exit_event_loop_on_close(true);
window->show();