Zum Inhalt springen
L

Das Video kommt von YouTube: erst beim Abspielen verbindet sich die Seite mit YouTube (Google).

Deadlock in Operating System | GeeksforGeeks

GeeksforGeeks4:33 157.875 Aufrufe veröffentlicht Auf YouTube

Das Wichtigste aus dem Video

Tipp auf eine Zeit – das Video springt genau dorthin.

Transkriptautomatisch erstellt · 32 Zeilen
Herunterladen
  1. Hello and welcome to Geeks for Geeks. In this video, we are going to understand a very important concept of deadlock in operating systems in a simple manner
  2. with the help of some real-life examples. So, let us understand deadlock by a real-life example. You can't get a job without experience and experience
  3. can only come when you do some job. So, here we end up in a deadlock. Let's see a formal definition of deadlock. So, deadlock is a situation
  4. where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process.
  5. Let us understand it with the help of an example. So, in this example, process one is waiting for resource Y but it is assigned to process two.
  6. Process two is not getting completed because it requires resource X which is assigned to process one ending up in a deadlock situation. Let's understand
  7. deadlock with one more real-life example of a wrongly managed school. The school never performs good in board exams. Almost all the students get failed. When
  8. the principal is asked why, his straightforward answer is that teachers doesn't teach well. When the teachers were asked about why the
  9. students were getting failed, they said that they were not given their wages. Then again, when the principal was asked why they are not giving the wages, he
  10. replies that parents don't want to pay the fees and he does not have the funds to give them. Pay to the teachers.
  11. The parents give the reason that school does not provide enough facilities but obviously principal cannot provide facilities unless the fees is paid
  12. which is depicted in this diagram and parents are not ready to pay the fees until facilities are enhanced in the school.
  13. So, here we end up in a deadlock situation and there's not much we can do for the school. In the previous example, we saw a
  14. deadlock between only two processes, namely school and parents. But a real operating system deadlock can be complex, and it usually involves
  15. multiple processes and resources. So, now we are going to study four necessary conditions for a deadlock to
  16. happen. So, they are mutual exclusion, hold and wait, no preemption, and circular wait. Let's see them all one by
  17. one. So, let's understand mutual exclusion. If some resources are non-shareable, which means that only a single process
  18. can use it. For example, here process one can use resource one, and no other process can use resource one. If this is not the case, then process cannot be
  19. stopped from using the resource when they require it. For example, full-screen processes in our computer cannot be used by two apps
  20. simultaneously. So, let's understand hold and wait now. If a process holds some resource and waits for some other resource, then the
  21. hold and wait is occurred. If this is not the case, then the cycle of deadlock, which we saw in the first diagram, will not get completed, and no
  22. deadlock will occur. The above school example is a classic example of hold and wait. As the school holds the facilities,
  23. and parents hold the resources. School needs the resources, and parent need the facilities. Hence, creating a hold and wait
  24. situation. Now, let's understand the third condition of no preemption. A resource cannot be taken from a
  25. process unless the process releases the resource. If preemption was allowed, deadlock would never occur because then there
  26. would have been no process able to hold a resource for long amount of time. For example, if your speaker is running an audio and after some time you click
  27. on some another audio, it starts playing it. But in case if no preemption was allowed, we would have to wait for the first audio to end. It was on an
  28. infinite loop. We will end up in a deadlock. So, let's understand the last condition, circular wait.
  29. A set of processes are waiting for each other in a circular form, then circular wait happens. For example, if you extend the first
  30. example to multiple processes and resources waiting for each other's held resources in a circular fashion, we will end up in
  31. a circular wait condition. So, hope you understood the concept of deadlock in operating system. Please don't forget to subscribe to the GeeksforGeeks YouTube
  32. channel and click on the bell icon.

Zum Nachlesen