I tried searching the net but couldn't find a perfect answer for this? What is the name of the procedure which is followed to avoid this situation where the other worker function will wait forever for this infinte loop to get over
-
You question isn't particularly clear, consider rewording it slightly. perhaps give an example. What situation, specifically, are you trying to avoid? – Ethan Field Aug 22 '17 at 12:26
-
Have you googled `NMI watchdog`? – myaut Aug 22 '17 at 13:25
2 Answers
if talking about processes infinite loop or no infinite loop linux does not care. the keyword you are looking for is 'preemption' and that can be looked up in any respectable os book
if there is an infinite loop not giving up the cpu in the kernel itself, that's a programming error. this is spotted with 'watchdog'.
Linux allows each thread of execution to run only for a specified quantum, before it is subject to being swapped out for another. It does not matter whether the process is in an infinite loop, the kernel has the power here.
As an aside (and I assume this is still the case with current kernels), threads which relinquish the CPU before their quantum is fully used can be given temporary priority boosts by the kernel as a reward for behaving nicely.

- 854,327
- 234
- 1,573
- 1,953
-
If a work queue is executing the the worker function in the same thread as work queue rather than creating a new thread for the worker function, then can it be swapped using preemption? – Shashwat KN Aug 23 '17 at 11:55