开发者

How often do deadlocks occur(about to occur) in an operating system

We study a lot about deadlocks in operating system courses. How often do they really occur ? or rather how often is there a chance for a deadlock(the OS actually doesn't let the dead lo开发者_Go百科ck to occur)?


I was asking the same question. I came across this in my textbook:

Expense is one important consideration. Ignoring the possibility of deadlocks is cheaper than the other approaches. Since in many systems, deadlocks occur infrequently (say, once per year), the extra expense of the other methods may not seem worthwhile.

It also mentions that if it occurs, the system would likely just slow down a bit, and eventually need a restart. Something we are all familiar with. The textbook quote is from page 323 of Brian, W.'s Operating System Basics.

But as Joao mentioned, it's up to the developer to produce quality code. So I guess in theory, if you were running a lot of junk programs you could face deadlocks regularly.


Deadlocks occur as often as you program multi thread programs with synchronizers and you don't know what you're doing.

You always have to release a mutex, for example, before placing the thread on wait as long as you need that same mutex to awake that thread, and that's just a small example.


Deadlock in multi threaded process of a user program will make the user application nonfunctional and this has got nothing to do with deadlock in operating systems. Deadlock in an operating system will occur if kernel allocates resource in an improper way and this happens very very rarely. The frequency is once in years and thus popular operating systems like Windows and Unix take the ostrich approach of ignoring the deadlock.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜