751 views
1 votes
1 votes

I am confused with what exactly Starvation mean ?

AFAIK Considering Process Scheduling eg SRTF and SJF , Starvation can be considered when some process is getting preempted by other high priority processes and hence not getting a chance to execute on CPU and hence is said to be "starving".

But, Considering Synchronization  eg TEST_AND_SET Lock ,

(1) TSL Ri,m[flag]

(2)CMP Ri,0

(3) JNZ to (1)

(4) **CS**

(5) Store m[flag],0

here also we say that starvation is there in the sense that ,

Suppose, Process P1 comes executes (1) to (3) and enters CS

Now, Processes P2,P3,P4,P5 comes and since flag=1 they loop in statements (1) to (3),

Now , P1 comes out of CS and sets flag=0, Now, Out of P2,P3,P4,P5  any one can go into CS first .

If the same scenario continues we could say any of P2,P3,P4,P5  may starve in the sense they never get access to CS but they obviously are executing on CPU.

Here, my confusion lies,

Starvation is w.r.t to getting executing on CPU or getting access to CS ?

PS: I have one more doubt , in synchronization ques , while solving do we consider a Single processor system or a Multiprocessor i.e. when we have multiple processing cores or CPUs available?

1 Answer

0 votes
0 votes

here  Processes P2,P3,P4,P5 comes ..but you can observe that they are not doing any useful WORK..

means yes they get CPU cycles..but what they are executing (checking flag)...is not a part of their program...

infact they are spending time to get CS...and CS contain such data which process want for their work....

so YES even they get the CPU cycles ..these cycles are used  to get access to the CS....

so starvation is in terms of CS...

in short they are not entering in CS...means not getting access to shared data ...logically they are STUCK..

(we generally assume only single processor) 

Related questions

1 votes
1 votes
2 answers
1
sumit chakraborty asked Nov 26, 2017
1,005 views
Given Processes P1: Wait(Sx); Wait(Sy); Do something;Signal(Sx); Signal(Sy); and Process P2: Wait(Sx); Wait(Sy); Do something;Signal(Sy); Signal(Sx); . Will it ever lead ...
0 votes
0 votes
0 answers
3
vijju532 asked Dec 14, 2018
229 views
I HAVE ONE DOUBT REGARDING THE STARVATION AND BOUNDED WAITING BOUNDED WAITING → ~STARVATION THEN USING THE CONCEPT OF CONTRAPOSITIVE IT CAN BE STARVATION → ~BOUNDED ...
0 votes
0 votes
1 answer
4