What is a Process vs a Thread, and what are the causes and conditions of a Deadlock?
Quick Revision Summary
Processes have isolated memory spaces; threads share memory within a process. Deadlocks require Mutual Exclusion, Hold & Wait, No Preemption, and Circular Wait.
Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Saved automatically
Model Answer & Deep-Dive Explanation
Process vs Thread:
- Process: Independent execution unit with its own dedicated virtual address space, file descriptors, and security context. Inter-process communication (IPC) requires sockets, pipes, or shared memory.
- Thread: Lightweight execution unit within a process. Threads share the process's heap, code segment, and global variables, but have their own independent Stack and Program Counter.
Coffman's Four Deadlock Conditions:
- Mutual Exclusion: At least one resource must be held in a non-shareable mode.
- Hold and Wait: A process must be holding at least one resource and waiting to acquire additional resources held by others.
- No Preemption: Resources cannot be forcibly confiscated from a process holding them.
- Circular Wait: A closed chain of processes exists such that each process holds at least one resource needed by the next.
Interviewer Evaluation Points & Scoring Rubric
- 1 1. Differentiates memory isolation between processes and threads. 2. Names all 4 Coffman conditions. 3. Mentions deadlock prevention strategies.
Related Questions in Computer Networks & OS
Why can adding more threads make a CPU-bound service slower?
Medium level • 5 views
What is the architectural difference between Docker Containers and Virtual Machines (VMs)?
Beginner level • 4 views
What happens step-by-step during a DNS Lookup when typing a URL into the browser?
Intermediate level • 4 views
A service name resolves correctly but connections time out. How would you investigate?
Medium level • 4 views
How does a TCP connection differ from an application-level session?
Medium level • 4 views