What Is a Process
Process Management & Scheduling · OS Core Internals track
6 min read
In this module
What Is a Process?
Launching a program is more involved than the operating system tossing your code at the CPU and stepping aside. The OS spins up an elaborate bookkeeping structure called a process: a running instance of a program with its own isolated memory, open files, and execution state.
A program is a static file sitting on disk. A process is that program brought to life, with the kernel tracking everything it needs to run.
The Process Control Block
The kernel needs somewhere to record all the metadata describing a running process. On Linux that structure is task_struct, and it's hefty: several kilobytes and well over a hundred fields, with the exact size depending on how the kernel was configured. Among the headliners:
pid- a unique integer identifying this processstate- whether the process is currently running, sleeping, or stoppedmm- a pointer to the memory management structure describing the process's address spacefiles- a table of open file descriptorsthread_info- low-level CPU state and kernel stack informationsched_entity- scheduling metadata so the kernel knows when this process should runsignal- pending signals waiting to be delivered
Most of those fields aren't the data itself but pointers to separate structures, and that detail matters later in the lesson. Threads in the same process each get their own task_struct, yet their mm, files and signal pointers all lead to the same shared objects.
A process is the kernel's abstraction for a running program. The process control block (Linux's task_struct) stores everything the kernel needs to manage it: its PID, memory layout, open files, scheduling state, and more.
Worked Example: Reading task_struct from User Space
You can't read task_struct directly, but Linux exposes most of it through the /proc filesystem. Every process gets a directory named after its PID, and /proc/self always points at whichever process is looking. Run this:
grep -E '^(Name|State|Pid|PPid|Threads|VmRSS)' /proc/self/statusYou'll get something like:
Name: grepState: R (running)Pid: 48213PPid: 48190Threads: 1VmRSS: 2304 kBEach line is a task_struct field or something derived from one. Pid is grep's own process ID, and PPid is its parent, the shell you typed the command into. State is the scheduler's view right now (grep is running, because it's the one reading the file). VmRSS is how much physical memory it's using, worked out from its mm structure. A few other entries are worth knowing:
| Path | What it shows |
|---|---|
/proc/<pid>/maps | Every mapped region of the address space, with permissions |
/proc/<pid>/fd/ | One symbolic link per open file descriptor |
/proc/<pid>/task/ | One subdirectory per thread |
/proc/<pid>/cmdline | The command line it was started with |
That last directory leads straight into the next idea.
Address Space Isolation
Every process gets its own virtual address space. From its own perspective, the process owns the entire memory range. It can't see or touch the memory of any other process. The hardware enforces this boundary through page tables managed by the kernel.
This isolation is fundamental to system stability. A bug in one process can't corrupt another process's memory. Dereference a wild pointer and only the offending process crashes.
// Each process sees its own independent address space// Process A and Process B can both have a variable at// the "same" virtual address - they map to different// physical memory.int global = 42; // This address is private to this processHere's what that looks like underneath. Suppose global sits at virtual address 0x404028 in both a parent and its forked child (the address is illustrative). Each process has its own page tables, selected by CR3 on x86-64 when the kernel switches to it, so the same virtual page resolves to different physical frames. After a fork() the two would briefly share a read-only frame, and the first write to it makes the kernel copy the page.
Processes vs Threads
A thread is a lighter-weight unit of execution living inside a process. Multiple threads within the same process share the same address space, file descriptors, and heap memory. Each thread has its own stack and register state. Everything else is shared.
That sharing is both the appeal and the hazard of threads. Communication between them is fast because they read and write the same memory directly. The flip side: one thread's bug can wreck data another thread depends on. Processes are safer; threads are faster.
On Linux, the kernel uses the same task_struct for both processes and threads. The clone() system call creates a new task and lets the caller choose what to share: memory, files, signal handlers. A thread is just a task that shares its parent's address space.
Predict: a program starts two extra threads, and all three print getpid() and gettid(). What do you see?
The same PID three times, and three different thread IDs. What user space calls the "PID" is really the thread group ID, shared by every thread in the process. Each thread is its own task with its own ID, which gettid() returns. The main thread's thread ID is equal to the PID, which is why single-threaded programs never notice the difference. You'll see the three IDs listed as directories under /proc/<pid>/task/.
Why Processes Matter for Security
For anyone leaning into security, the process model is the first line of defence. Mitigations like ASLR (address space layout randomisation) operate at the process level: each process gets its own randomised memory layout. Sandboxing technologies confine a process's capabilities, limiting which files it can touch and which system calls it can make.
The /proc filesystem cuts both ways. It's where defenders look to see what a suspicious process is up to: its command line, its open files, its memory map. It's also where malware looks to find other processes worth attacking, which is why hardened systems restrict how much of /proc one user can see of another user's processes.
Understanding what a process is, what state the kernel maintains, and how isolation works underpins everything that follows: scheduling, memory management, exploitation, all of it.