{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

22 Deadlocks and Starvation

22 Deadlocks and Starvation - CS-350 Fundamentals of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS-350: Fundamentals of Computing Systems Page 1 of 12 Lecture Notes © Azer Bestavros. All rights reserved. Reproduction or copying (electronic or otherwise) is expressly forbidden except for students enrolled in CS-350. Concurrency and Synchronization: Deadlocks and Starvation As we have observed when discussing the dining philosophers problem, deadlock and thus the possibility of starvation should be a matter of concern whenever entities (such as processes, threads, applications, etc.) compete for resources, and may block waiting for them to become available. For the dining philosopher problem, we saw how one may rely on knowledge of the specific problem at hand to find a “clever” way to ensure that deadlocks/starvation will not occur. Generally speaking, however, this is not a practical approach. In particular, it will be quite hard to generalize to larger problems or more complicated scenarios when multitudes of resources of different types and many competing processes are involved. What we need is a disciplined approach for how to manage synchronization in such a way that does not allow for deadlocks to occur. Deadlock: A Definition A deadlock involves conflicting needs for resources by two or more processes. It is defined as a “permanent blocking of a set of processes that either compete for system resources or communicate with each other.” Before we proceed in discussing what we can do about deadlocks, it is important to note that in general there is no “silver bullet” for dealing with deadlocks. Indeed, in many systems (e.g., operating systems such as Windows or Unix SVR4) deadlocks essentially ignored—they are a necessary evil that we just deal with when they occur (perhaps by pushing the dreaded “ctrl-alt- del” combination of keys). Understanding how deadlocks occurs Deadlock occurs when processes have no way of making progress. To illustrate this point, we consider the simplest case of two processes P and Q and discuss how they could get “stuck” in a deadlock. Clearly, if P and Q do not have any common resources that they need in order to make progress, then there is absolutely no danger of them being deadlocked. In other words, in such a situation, P and Q can each make progress independent of the other; there is no way for one process to impede the progress of the other since they have nothing in common. In our illustrative “Dining Philosophers” problem, if the philosophers (processes) did not have to share the chopsticks, we would not have had to worry about deadlocks. Now, let’s assume that P and Q do indeed share resources. Could that lead to a deadlock? The answer is that it depends on the type of resources they share. Specifically, two possibilities exist. The resources shared allow for multiplexed use – i.e., multiple processes are able to make progress by interleaving the use of any shared resource. Examples of such resources would
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS-350: Fundamentals of Computing Systems Page 2 of 12 Lecture Notes © Azer Bestavros. All rights reserved.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 12

22 Deadlocks and Starvation - CS-350 Fundamentals of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online