0 votes 0 votes Why would a thread ever voluntarily give up the CPU by calling thread yield? After all, since there is no periodic clock interrupt, it may never get the CPU back. Operating System tanenbaum operating-system process-and-threads interrupts descriptive + – admin asked Oct 24, 2019 admin 1.7k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes Answer: A thread will voluntarily give up the CPU by calling thread yield because of the following reasons: Thread in a process cooperate with each other and if a yielding is needed for the betterment of the application, then the thread will yield for sure. Also, usually the same program writes the code for all the threads in one process. There is no thread scheduler like in the OS. Hence, the programmer doesn't want a thread to go wild and takes the CPU time of the processes forever. To prevent a deadlock of the resource, it might be necessary for a thread to yield itself for continuing the process successfully. `JEET answered Oct 25, 2019 `JEET comment Share Follow See all 0 reply Please log in or register to add a comment.