Explain the fundamental differences between a process and a thread. How do they differ in terms of memory sharing and overhead?
Last updated
A process is an independent program in execution with its own private address space; a thread is a lightweight unit of execution that lives inside a process and shares that address space with sibling threads. Processes isolate; threads share.
Memory sharing:
Processes have separate address spaces: they must use IPC (pipes, shared memory, sockets) to communicate.
Threads share the same heap, code, and global data, so communication is just shared memory (but needs synchronization).
What's private: Each thread has its own stack, registers, and program counter; each process has its own everything.
Overhead:
Creating a process is expensive (new address space, page tables); creating a thread is cheap.
Context switching between processes needs an address-space (page table / TLB) swap; between threads it doesn't.
Isolation and failure: A crash in one process doesn't affect others; a crash (or memory corruption) in one thread can take down the whole process.
- https://growthequityinterviewguide.com/firms/b-capital
- https://www.interviewbit.com/sre-interview-questions/
- https://www.reddit.com/r/cscareeradvice/new/
- https://www.reddit.com/r/macbook/comments/1jg7fl6/24gb_ram_enough_for_software_engineering/
- https://www.reddit.com/r/infosys/comments/1t71add/anyone_received_round_2_mails/
- https://www.reddit.com/r/cscareeradvice/best/
- https://www.reddit.com/r/LeetcodeChallenge/
- https://www.reddit.com/r/infosys/comments/1t71i55/infosys_specialist_programmer_april_26_1st_round/
- https://www.reddit.com/r/programming/comments/1hqo19u/static_search_trees_40x_faster_than_binary_search/
- https://medium.com/@avinashkumar808482/operating-system-interview-questions-2026-0db6b4674980
- https://lmskkhsou.in/eservices/e-Resources/Resources/NEP%20Syllabus%202024/core/BCA_Syllabus.pdf