diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-17 14:48:55 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-17 23:16:14 +0200 |
commit | c02c6fef285863427ae0c3c278e3f48fb5ae381f (patch) | |
tree | ad9cb771ecbd86652a2a65f866320c2f03687797 /Kernel | |
parent | c59f8cd66388f789668d083d2c43226a50b71c08 (diff) | |
download | serenity-c02c6fef285863427ae0c3c278e3f48fb5ae381f.zip |
Kernel+ProcessManager: Show per-process syscall counts.
Added a simple syscall counter to the /proc/all contents. :^)
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 5 | ||||
-rw-r--r-- | Kernel/Process.h | 5 | ||||
-rw-r--r-- | Kernel/Syscall.cpp | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index b0d26c7fe2..4dd4810c21 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -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()); diff --git a/Kernel/Process.h b/Kernel/Process.h index 9cfe73b36f..6c95fc644e 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -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; }; diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index bafad9bddd..34b817bd5d 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -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: |