Zum Inhalt springen
L

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

Deadlock - Operating Systems | Simply Explained

TechPrep5:06 11.976 Aufrufe veröffentlicht Auf YouTube

Das Wichtigste aus dem Video

Tipp auf eine Zeit – das Video springt genau dorthin.

Transkriptautomatisch erstellt · 41 Zeilen
Herunterladen
  1. so what actually is deadlock so deadlock is a situation in an operating system where two or more processes are unable to proceed because each is waiting for
  2. one of the others to release a resource and that resource could be Memory it could be files it could be printers so let's say we have process one and it is
  3. waiting to get access to Resource One however resource one has already been assigned to process 2 and process 2 is waiting to get access to Resource 2
  4. which has already been assigned to process one and so here we have a circular chain and as you can see process one will never never be able to
  5. access Resource One because that has already been assigned to process two and process two is waiting for resource 2 which has already been assigned to
  6. process one and therefore we have deadlock a deadlock can only occur if the following four conditions are met simultaneously the first one is mutual
  7. exclusion and so what does that mean only one process can use a resource at any one time if a process has taken a resource no other process can use it
  8. until it is released so an analogy is think of a single lane bridge where only one car can pass at a time if car is on the bridge no other car can enter until
  9. the first car has crossed and left the bridge the second condition is hold and weight and what this means is a process is holding at least one resource and is
  10. waiting to acquire more resources that are currently being held by other processes an analogy is imagine a dinner table where Bob is holding a fork and he
  11. needs a knife to e and so he waits for a knife that Mary is using at the same time Mary is holding a knife and is waiting for a spoon Bob is using and so
  12. both are holding one thing but waiting for another the third condition is no preemption and what is does this mean this means that a resource cannot be
  13. forcibly taken from a process a process must release its resources voluntarily and an analogy is like being at a library with a rule that says you can't
  14. take a book from someone else until they're done with it and so if everyone holds on to their books and waits for others to finish without reading theirs
  15. no one will give up their book and everyone ends up waiting indefinitely the fourth and final condition is circular weight and this means that
  16. there is a set a circle of processes each waiting for a resource that the next process in the circle holes and so we've already seen this in the first
  17. example where there's a circular nature of processes that are waiting for a resource being held by another process another key topic is deadlock prevention
  18. and so prevention focuses on structurally eliminating the possibility of Deadlock by negating at least one of the four necessary conditions so mutual
  19. exclusion hold and weight no preemption and circular weight an example is lock ordering and so this breaks the circular weight condition and so what is it this
  20. involves imposing a total ordering of all resource types and requiring that each process requests resources in an increasing order of enumeration and so
  21. how this is done for example is that if we have resources labeled or one or two or three or four and or n then our process must request these resources in
  22. order so it must request or one before it requests or two it must request or two before or three or three before or four and or four before or n and this
  23. ordering prevents circular weights and in the real world this is widely used in database and file systems there is also deadlock avoidance and avoidance is all
  24. about dynamically examining the the state of resource allocation and ensuring that the system can always reach a state where all processes can
  25. complete their tasks one example is Banker's algorithm and so this is a strategy used to avoid deadlock by simulating resource allocation for all
  26. possible sequences and determining if a safe sequence exists and so this is done by before granting a resource the system checks if doing so will leave the system
  27. in a safe state where all processes can still complete with the resources available Banker's algorithm is more theoretical because its overhead can be
  28. quite high in systems with many process and resources and it's not commonly used in most operating systems due to its complexity but might be seen in systems
  29. with highly critical and predictable processes however in reality while theoretical models of Deadlock prevention and avoidance are well
  30. defined the actual implementation tends to prefer practicality and efficiency and so techniques like lock ordering monitoring and judicious uses of
  31. timeouts form the backbone of handling deadlocks in most real world applications and to recap the definition deadlock is a situation in an operating
  32. system where two or more processes are unable to process because each is waiting for one of the others to release a resource the four necessary conditions
  33. for deadlock include Mutual exclusion so only one process can use a resource at any one time hold and wait a process is holding at least one resource and is
  34. waiting to acquire more resources that are currently being held by other processes no preemption so a resource cannot be forcibly taken from a process
  35. a process must release its resources voluntarily and finally circular weight there's a set a circle of processes each waiting for a resource that the next
  36. process in the circle holds then we have prevention which focus on structurally eliminating the possibility of Deadlock by negating at least one of the four
  37. necessary conditions and avoidance which dynamically examines the state of resource allocation and ensures that the system can always reach a safe state
  38. where all processes can complete their tasks in the real world actual implementation tends to prefare practicality and efficiency I hope this
  39. was a clear explanation of what deadlock is the conditions required for it and how it can be prevented and avoided if you want more in detail Technical
  40. Solutions make sure to like And subscribe and also don't forget to check out Tech prep. if you want to see the most upto-date technical interview
  41. questions and solutions thanks for watching and I'll see you in the next one

Zum Nachlesen