Abstract


Kernel not a process!

OS System Program like the Init System and the shell are processes, but the kernel itself isn’t a process!

Communication among processes

Process usually don’t share Memory Frames among themselves for isolation purposes. We need Inter-Process Communication for communication among processes.

Process memory usage

You can check the detailed breakdown of process memory usage but cat /proc/<pid>/statm on Linux Kernel. You refer to ChatGPT to make sense what the value represent.

Info

VmSize represents the size of Virtual Memory assigned to a process.

VmRSS represents the size of Memory Frames a process is currently using.

Debugging in Linux

gcore lets you take a full snapshot of a running process’s memory so you can debug it later in gdb, while gstack is a quick way to inspect all thread stack traces on the spot to see what each thread is doing (blocked on a syscall, stuck on a lock, sleeping, etc).

They rely on ptrace, so you’ll need proper permissions, matching namespaces, and relaxed kernel policies if you’re inside containers or hardened environments. In short, gcore is for deep post-mortem analysis, and gstack is for fast, live insight into why your program might look stuck.

Core Image

Child Process

  • Has the same UID as its parent

Process Resources

Process State


  • Ready to Run: could be running but CPU gave processing power to some other processes
  • Block: process is waiting for things like I/O to finish working (eg. waiting for file to be read)

Queuing Model for State Transition

  • Ready queue to hold the processes that are ready to run
  • Blocked queue to hold processes that are waiting for things like I/O to finish working (eg. waiting for file to be read)

procs


  • A ps replacement written in Rust
brew install procs # Installation 
 
# Alias to ps, and add in config file, add the following line to .zshrc
alias ps='sudo procs --load-config <path_to_your_config.toml>' # Refer to https://github.com/dalance/procs?tab=readme-ov-file#configuration for more info on the config.toml

OG ps

Given 4327 ttys002 0:07.79 /opt/homebrew/bin/zsh -il, it means:

a zsh process is running on terminal session ttys002 with a process ID of 4327, accumulating a total CPU time of 0:07.79, which translates to 0 minutes and 7.79 seconds.