Skip to content

19. Banker's Algorithm vs Detection Algorithm

They look almost identical (both use a vector-relaxation loop), which confuses people, but timing/intent/data differ completely:

  • Banker's Algorithm (avoidance): runs before allocation, using a pessimistic Need matrix (Max − Allocation). Refuses a request if it might lead to deadlock.
  • Detection Algorithm: runs after allocation, using a Request matrix (actual current requests). Makes no assumptions about the future — only catches deadlocks that have already happened.

Memory rule: Banker's = a bank deciding whether to give a loan (before, avoidance). Detection = a doctor checking if a patient is currently sick (after, detection).