In a work queue, if a function is hogging the system(eg. running an infinite loop), how will the kernel know that it is hogging and it has to either preempt or cancel the work?
Asked
Active
Viewed 27 times
0
-
*Every* thread gets preempted at the end of it's timeslice – Caleth Aug 23 '17 at 13:25
-
but what if there is an infinte loop, will it preempt it forever? – Shashwat KN Aug 24 '17 at 09:38
-
In general, yes. Note that there are a number of programs (e.g. basically all GUI programs) whose "normal running" is indistinguishable from "infinite loop", right up until the point where they end. Each thread that is runnable (disregarding priority) will get *some* timeslices, that's the *point* of a scheduler – Caleth Aug 24 '17 at 09:40