G'day all. Quoting Paul Graunke <ptg@ccs.neu.edu>:
Right, cooperative multitasking is faster than preemptive multitasking.
That's often the case, but it depends. Some OSes have very, very fast thread primitives. It also depends on the application, as I noted, because what you lose in system call overhead you can win back elsewhere.
One technique is to have several OS threads to make use of CPUs and do your own scheduling inside that.
That certainly works. The "thread pool" approach is the simplest incarnation of this.
Is there a problem with having a system thread do the IO based on pulling events from a channel and pushing the results back to a channel? You can push the result channel/mvar through the request channel along with the request.
Unfortunately, I can't think of a way to make this work with memory mapped files, which are pretty important these days. Cheers, Andrew Bromage