Das Video kommt von YouTube: erst beim Abspielen verbindet sich die Seite mit YouTube (Google).
Deadlock - Operating Systems | Simply Explained
Das Wichtigste aus dem Video
Transkriptautomatisch erstellt · 41 Zeilen
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- and so prevention focuses on structurally eliminating the possibility of Deadlock by negating at least one of the four necessary conditions so mutual
- 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
- involves imposing a total ordering of all resource types and requiring that each process requests resources in an increasing order of enumeration and so
- 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
- 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
- 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
- about dynamically examining the the state of resource allocation and ensuring that the system can always reach a state where all processes can
- 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
- 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
- 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
- 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
- with highly critical and predictable processes however in reality while theoretical models of Deadlock prevention and avoidance are well
- defined the actual implementation tends to prefer practicality and efficiency and so techniques like lock ordering monitoring and judicious uses of
- timeouts form the backbone of handling deadlocks in most real world applications and to recap the definition deadlock is a situation in an operating
- 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
- 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
- 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
- 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
- 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
- necessary conditions and avoidance which dynamically examines the state of resource allocation and ensures that the system can always reach a safe state
- where all processes can complete their tasks in the real world actual implementation tends to prefare practicality and efficiency I hope this
- 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
- 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
- questions and solutions thanks for watching and I'll see you in the next one