Eduardo Humberto
Eduardo Humberto

Reputation: 485

Does First-Come, First-Served (FCFS) Scheduling avoids deadlock?

Is it guaranteed that by using FCFS scheduling, the 'system' will not be in deadlock?

Thanks in advance!

Upvotes: 1

Views: 829

Answers (2)

camelCase
camelCase

Reputation: 80

The four conditions for a deadlock are:

  1. Mutual exclusion: Irrespective of the scheduling algorithm, resources can be possessed by one process without sharing.
  2. Hold and wait: In this condition, processes can wait for other resources while holding onto one resource. This is possible with any scheduling algorithm.
  3. No preemption: FCFS is non-preemptive. That is, processes executing a critical section of their code cannot be forced to stop.
  4. Circular wait: Processes are waiting for another process to release a resource in a circular fashion. This, again, is irrespective of the scheduling algorithm

Hence, FCFS does not guarantee that the system will not be in deadlock. If the four conditions are met, a deadlock will occur.

Upvotes: 2

Timir
Timir

Reputation: 1425

Deadlocks are caused by resource locking, not scheduling order. FCFS doesn’t guarantee that your threads will always grab resources in sequence, so the answer to your question is no.

Upvotes: 1

Related Questions