开发者

How do I determine whether a deadlock will occur in this system?

N processes share M resource units that can be reserved and release only one at a time. The maximum need of each process does not exceed M, and the sum of all maximum needs is less than M+N. Can a deadlock 开发者_开发问答occur in the system ?


I hope you got the answer. Answering this question for other visitors.

The answer is that the deadlock will not occur in the system.

The proof is given in the image below.

The image was taken from http://alumni.cs.ucr.edu/~choua/school/cs153/Solution%20Manual.pdf on page 31


the system you are describing looks like semaphores

about your last question : YES. You "could" always do a deadlock ; if you don't see how, ask a young/shameful/motivated/deviant developer.

One good way to make a good one ; is to have strange locking/releasing resources rules. For example, if a process needs M resources to perform a task, he could locks half of them right away, and then waits for the other half to be available before doing anything.

I assume he never gives up until he have its M precious resources and releases them all once the task done.

A single process wouldn't cause much problems but several will as they will lock more than M total resources and will need more of them to get out this frozen state.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜