3 ms·
Perhaps what is wanted is an easier/better threading model? If I read from a file, my code to blocks while the operating system reads the file. If I want to do
by fragmede 17y ago
Perhaps what is wanted is an easier/better threading model? If I read from a file, my code to blocks while the operating system reads the file. If I want to do something else, I can create a new thread which does the reading while the original thread does something else.
Unfortunately, our current model has threading a bit like a bull in a China shop as it creates a whole host of concurrency problems in anything more complex than a trivial example. The 'select' call is a reasonable half-measure, as your 'read' call is non-blocking when you get to it.
I question the threading model, as it definitely has problems, but in terms of having multiple tasks, and an event loop, and scheduling those tasks, the operating system already has that, should we really re-implement it?
- barrkel 17y agoThe OS should definitely supply some kind of user-side task scheduling framework. Ideally your task scheduling framework will have as many threads as the machine has processors, and will use e.g. work-stealing queues to dispatch work without needing a kernel transition that a thread or process context switch would require. But if every running process implements its own task scheduling framework, and creates as many threads as there are processors, there will be too many threads running around. The OS needs to help out with balancing the load.