Re: OS with single process and global event loop
Posted: Fri Jan 08, 2021 1:30 pm
If all you care about is throughput, then a global event loop would be pretty efficient. But, even languages such as Javascript eventually introduced threads ("Web Workers") for those long CPU heavy processes. You could do something similar, have your main event loop (which can support coroutines - yielding a coroutine throws it on the end of the event queue), and if you wanted to do something heavy such as video decoding, you could explicitly spawn a thread so this wouldn't hold up procesing.
You could even do something where you reset the system timer at the start of calling an event, and if uses up an entire time slice (say 100ms), you promote the event into a thread. But, there are caveats with this as you'd have to assume all code could potentially be executed in parallel.
You could even do something where you reset the system timer at the start of calling an event, and if uses up an entire time slice (say 100ms), you promote the event into a thread. But, there are caveats with this as you'd have to assume all code could potentially be executed in parallel.