While a resource is holding a lock
all other resources that want to acquire the lock
must wait.
Reasons for a deadlock:
- Mutual Exclusion
- Limited access or limited quantity of a resource
- Hold and Wait
- A process holding a resources acquires other resources without releasing previous resources
- No Preemption
- One process cannot forcibly remove another process' resource
- Circular Wait
- Two or more processes wait for another resource in the chain
Thread | Process |
---|---|
exists within a process | instance of a program |
shares process' resources | separate address space |
threads share same heap space | inter-process communication to access variables of other process (pipes, files, sockets) |
- Time spent to switch between processes
- Scheduling is part of the operating system