3 ms·
I think the implicit idea is that the CPU bound thread only is kept busy in smallish chunks, and you’d inject a stop package in its stream of work.
by actionfromafar 3y ago
I think the implicit idea is that the CPU bound thread only is kept busy in smallish chunks, and you’d inject a stop package in its stream of work.
- cesarb 3y agoYou're assuming that the work can be split into "smallish chunks", instead of a single large CPU-bound computation. Sure, "injecting a stop package in its stream of work" is the best design, but only if you do have a stream of work in the first place. Otherwise, it's either signals, or constantly checking a shared "stop" variable in the middle of a very hot CPU-bound loop.
- gavinhoward 3y agoYes, but how do you limit the size of those chunks? Perhaps only do one math operation? Calculating 2^4294967296 is one operation, but it can take minutes (hours?) on my bc. Do you want it to take that long, not responding to SIGINT the entire time? Probably not. Smaller chunks? Then you have to check for signal in a loop, which causes its own problems. I used to do that, and as I told boffinAudio, that caused problems with state being invalid and such.