s ravi chandran wrote:Thanks for the reply. He just said relinquish control. But is it possible for a thread to relinquish control without releasing the lock on object? then what would be the benefit of thread scheduler giving control to other thread?
Let's try a real world analogy. We have three people (threads):
A(lice) - Responsible for writing a letter and handing it to Bob to mail.
B(ob) - Responsible for mailing the letter
C(harlie) - Responsible for having lunch
Let's suppose the task schedule starts with Bob. Bob realizes he can't do anything without the letter and waits (relinquishes control) of the the CPU. This lets Alice or Charlie do their job while Bob has voluntarily waited. I think the is the scenario they are thinking of.
Now let's suppose that Alice takes 20 minutes to write the letter. The task scheduler decided it would be nice to give Charlie a turn. Charlie isn't waiting for either Alice or Bob. He can run as soon as he gets a turn. I don't think this is scenario they are thinking of, but it is equally viable.