mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:17:44 +00:00
Kernel+ProcessManager: Show per-process syscall counts.
Added a simple syscall counter to the /proc/all contents. :^)
This commit is contained in:
parent
c59f8cd663
commit
c02c6fef28
6 changed files with 22 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -579,7 +579,7 @@ ByteBuffer procfs$all(InodeIdentifier)
|
|||
auto processes = Process::all_processes();
|
||||
StringBuilder builder(processes.size() * 80);
|
||||
auto build_process_line = [&builder] (Process* process) {
|
||||
builder.appendf("%u,%u,%u,%u,%u,%u,%u,%s,%u,%u,%s,%s,%u,%u,%u,%u,%s\n",
|
||||
builder.appendf("%u,%u,%u,%u,%u,%u,%u,%s,%u,%u,%s,%s,%u,%u,%u,%u,%s,%u\n",
|
||||
process->pid(),
|
||||
process->main_thread().times_scheduled(), // FIXME(Thread): Bill all scheds to the process
|
||||
process->tty() ? process->tty()->pgid() : 0,
|
||||
|
@ -596,7 +596,8 @@ ByteBuffer procfs$all(InodeIdentifier)
|
|||
process->amount_resident(),
|
||||
process->amount_shared(),
|
||||
process->main_thread().ticks(), // FIXME(Thread): Bill all ticks to the process
|
||||
to_string(process->priority())
|
||||
to_string(process->priority()),
|
||||
process->syscall_count()
|
||||
);
|
||||
};
|
||||
build_process_line(Scheduler::colonel());
|
||||
|
|
|
@ -247,6 +247,9 @@ public:
|
|||
|
||||
Lock& big_lock() { return m_big_lock; }
|
||||
|
||||
unsigned syscall_count() const { return m_syscall_count; }
|
||||
void did_syscall() { ++m_syscall_count; }
|
||||
|
||||
private:
|
||||
friend class MemoryManager;
|
||||
friend class Scheduler;
|
||||
|
@ -322,6 +325,8 @@ private:
|
|||
|
||||
int m_next_tid { 0 };
|
||||
|
||||
unsigned m_syscall_count { 0 };
|
||||
|
||||
Lock m_big_lock;
|
||||
};
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ int sync()
|
|||
|
||||
static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2, dword arg3)
|
||||
{
|
||||
current->process().did_syscall();
|
||||
|
||||
ASSERT_INTERRUPTS_ENABLED();
|
||||
switch (function) {
|
||||
case Syscall::SC_yield:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue