• edited by
13,631 views
53 53 votes

An operating system handles requests to resources as follows.

A process (which asks for some resources, uses them for some time and then exits the system) is assigned a unique timestamp are when it starts. The timestamps are monotonically increasing with time. Let us denote the timestamp of a process $P$ by $TS(P)$.

When a process $P$ requests for a resource the $OS$ does the following:

  1. If no other process is currently holding the resource, the $OS$ awards the resource to $P$.

  2. If some process $Q$ with $TS(Q) < TS(P)$ is holding the resource, the $OS$ makes $P$ wait for the resources.

  3. If some process $Q$ with $TS(Q)>TS(P)$ is holding the resource, the $OS$ restarts $Q$ and awards the resources to $P$. (Restarting means taking back the resources held by a process, killing it and starting it again with the same timestamp)

When a process releases a resource, the process with the smallest timestamp (if any) amongst those waiting for the resource is awarded the resource.

  1. Can a deadlock over arise? If yes, show how. If not prove it.

  2. Can a process P ever starve? If yes, show how. If not prove it.

6 Answers

Best answer
59 59 votes
  1. Can Deadlock occur. No, because every time Older Process who wants some resources which are already acquired by some younger process. In this condition Younger will be killed and release its resources which is now taken by now older process. So never more than one process will wait for some resources indefinitely. Timestamp will also be unique.
  2. Can a process Starve. No, because every time when Younger process is getting killed, it is restarted with same timestamp which he had at time of killing. So it will act as an elder even after killing for all those who came after it..

There is No starvation. Consider this scenario:

Say a process $p_{12}$ with TS $12$ and another process $p_{11}$ with timestamp $11$ so,  $p_{12}$ gets killed but again come with same timestamp. As timestamp is increasing for newly enter process so  at next process $p_{13}$ enter with timestamp $13$ which have greater timestamp than $p_{12}$ so, $p_{12}$ gets executed. Hence there is no starvation possible.

• edited by
11 11 votes
Its wound-wait protocol of database, which is deadlock-free and starvation-free.
2 2 votes

The process will starve if it is restarted with a newer timestamp. This will lead to the process to get killed all the time and get renewed with being the same younger ( junior ) process, and hence, starve

0 0 votes
any deadlock? no

but I Think the process will starve, imagine the one with the highest time stamp,it gets killed by a younger process,it has to start with the same time stamp, even though it gets hold of a resource it is always killed.secondly whenever any process releases a resource,the one with the smallest time stamp is awarded the resource, so the one with the highest time stamp in the entire system will starve prvided new processes with lower time stamps keep coming.
0 0 votes
there is no starvation and no deadlock possible in given que. if someone says possible then how.....????
• reshown by
0 0 votes
Lets deal with question a bit differently.

Suppose in a house there are 5 members. Grand father , Father , Mother , Elder Brother(B) , Youngest Sister(S). There is only one tv in the house.

Now the rule in the house is : 1)If any younger family member is watching tv and an elder member joins then elder member will watch tv and younger had to leave.

2)If elder member is watching tv and any younger member joins , then younger member will keep waiting till older member is watching tv.

3)Every member watches tv only once(this we have taken because an older process will keep its execution continue till the end as it will kill all the younger process in the meantime to get resources.This means older process will stop only after complete execution)

4) Only younger members can join the family in future like if a new member joins after S then it needs to be younger ( This rule is applied because process with younger time stamps will join . Process with older timestamps are already present. Whatever new process comes it will have a younger timestamp)

Deadlock: will there be deadlock?

No

Explanation:  If mother  is watching tv and B joins then B will wait .Suppose B is already waiting and S also joins in then she will also wait.

Now mother  was about to leave and B was happy that he will get the chance but in the meantime Father joins in.

So as per the rule:  As mother left , father is the eldest so he gets the chance to watch tv and B and S keeps on waiting.

But but but

Father was watching and grandfather joins so father gives the remote to grand father and waits for his chance.

Eventually grandfather leaves then father watches tv then he leaves then son watches and then sister.

So there can never be a deadlock.

PS : There was chance of deadlock if elder member comes back to watch tv even after watching it one time but this will not happen as per our rules

Starvation: Will it happen?

No

Explanation: It's clear now that if older member joins the younger members will wait for there chance and they will get it eventually. What if more younger members join ?

Suppose B is watching tv and S is waiting and one more member joins who is younger, say Q .

If this happens still there is no problem because Q is younger and younger members keep waiting till elder members finish watching tv .

So no deadlock and no starvation

 
Position:
Show:

Related questions

30 30 votes
7 answers 7 answers
23.2k
23.2k views
Kathleen asked Sep 29, 2014
23,245 views
An operating system contains $3$ user processes each requiring $2$ units of resource $R$. The minimum number of units of $R$ such that no deadlocks will ever arise is$3$$...
21 21 votes
2 answers 2 answers
6.6k
6.6k views
go_editor asked Feb 8, 2018
6,637 views
Consider the following relational database schema:EMP (eno name, age)PROJ (pno name)INVOLVED (eno, pno)EMP contains information about employees. PROJ about projects and i...
21 21 votes
1 answers 1 answer
5.6k
5.6k views
go_editor asked Oct 14, 2015
5,611 views
Following floating point number format is given$f$ is a fraction represented by a $6-bit$ mantissa (includes sign bit) in sign magnitude form, $e$ is a $4-bit$ exponent (...
5 5 votes
1 1 answer
2.0k
2.0k views
Kathleen asked Sep 29, 2014
1,961 views
The language $L,$ defined by the following grammar, allows use of real or integer data in expressions and assignment statements.<assign-stmt :: <LHS := <E <E ::...