|
Boost : |
Subject: Re: [boost] Cooperative Multi-Tasking
From: Ian Emmons (iemmons_at_[hidden])
Date: 2010-03-04 09:38:09
On Mar 3, 2010, at 3:37 PM, Daniel Larimer wrote:
> I am curious whether anyone here has experience with any cross-platform cooperative multi-tasking libraries? I am familiar with the Boost.Coroutine library, but it only provides the "primitives" or "threads". What I am looking for is something much higher level that hides all of the coroutine details behind a asynchronous function call / future API. Something along the line of ASIO for coroutines.
>
> I am guessing that Boost.Asio would benefit from such a library. It seems obvious to me now that coroutines / cooperative multi-tasking is the superior approach to solving problems with a large number of actors and "locks" where heavy weight preemptive scheduling would bog down the system.
>
> Considering that cooperative multitasking is a very old concept, are there any reasons why there are no obvious libraries / scheduling systems in place? Does everyone "roll their own" or do they avoid it for some other reason?
>
> Dan
My own experience (quite old now) with cooperative multitasking comes from Windows and Macintosh GUI programming back around 1990, before Windows and Macintosh had the modern concepts of process or thread. Your app consisted of a loop that fetched the next message/event and then acted on it. In that model, there was a single thread running all the applications on the system. It switched between applications by returning from the "get next message" system call in the message loop of whatever application it wanted to run next.
Is that what you mean by "cooperative multitasking" here? If so, I would agree that it has some utility. However, it singularly fails to utilize multiple cores/processors, which is an important thing in today's world of static CPU speed and rapidly increasing core density. It also suffers from increased reliability problems, because it is harder in that model to isolate tasks from faults in other tasks.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk