What is a process?
Answer
A process is a program in execution — an active entity with its own memory space, system resources, and execution context. A program is a passive, stored set of instructions (binary on disk); a process is that program being actively run. Process components: (1) Code segment (text): the executable instructions; (2) Data segment: global and static variables; (3) Heap: dynamically allocated memory (malloc/new); (4) Stack: local variables, function call frames, return addresses; (5) Process Control Block (PCB): OS data structure storing process state — PID, program counter, CPU registers, memory maps, open files, process state. Process states: New (being created) → Ready (in queue, waiting for CPU) → Running (executing on CPU) → Waiting/Blocked (waiting for I/O, event) → Terminated (finished or killed). Process vs program: one program can spawn multiple processes (browser tabs). Multiple processes can run the same program simultaneously (multiple users running ls). Multiprogramming vs multitasking: multiprogramming = multiple programs loaded in memory at once; multitasking = rapid CPU switching among them giving illusion of simultaneous execution. Process creation: fork() (Unix) creates a child process as a copy of parent; exec() replaces process image with a new program; CreateProcess() (Windows). Process overhead: processes have high overhead — separate memory space, creation is expensive. Threads within a process share memory, are cheaper to create.