441 views
0 votes
0 votes
Deadlock does not occurs with single resource why?

Is Single resource can't be in shareable mode?

1 Answer

0 votes
0 votes

Depends what you are considering as resource,

if it is file, it can be shared by multiple read process, but can only be write by any process if no read processes or other write process is accessing it.

if it is a reentrant code, then also it can be shared by multiple users -- remember it's the single copy of both, which everybody is using.

Or it could be common memory area, generally, Producer-Consumer, Reader-Writer algorithms are used for this purpouses.

now if it's physical resource, then your assertion "Deadlock does not occurs with single resource", is wrong so there is no, "why?" exists.

Although, you require Resource allocation graph to decide weather there is Deadlock or not. If there is cycle, present in graph then it's a deadlock.(But, remember if there are multiple resource, even cycle doesn't guarantee that there is deadlock.)

But, let's consider an example to make things clear here and now, let there are two processes P1 and P2, and there are two resources A and B,

A is acquired by P1 and requested for B, B is acquired by P2 and requested for A. Use your imagination!!!

Related questions