Coming IO features in Tango

Sean Kelly sean at f4.ca
Wed Jul 25 08:50:39 PDT 2007


Paul Findlay wrote:
> Ingo Oeser wrote:
>>> Fibers, Greenthreads and user space threading stuff like that proved to
>>> be a can of worms already and is only necessary, if the native thread
>>> implementation of an OS sucks.
> 
> Sean Kelly wrote:
>> Fibers/Coroutines are useful in that they vastly simplify the creation
>> of state machines in many cases.  They certainly aren't suitable for
>> every task, but I think they have enough general utility that they
>> should be available to the user.
> 
> Are fibers able to take advantage of the machine's cache any better than
> swapping threads (with their dramatically larger stack space) in and out?

Probably not.  But context switching fibers is much faster than context 
switching threads, which is a selling point in some cases.  Another 
being that a non-running fiber can be passed between threads just like a 
delegate.

 > I
> sort of imagine a whole bunch of fibres allocated in a contiguous block of
> memory are going to be much better off than a whole bunch of threads
> allocated in a similar manner and doing a similar job. Unfortunately I have
> nil experience with fibers and therefore no way to validate this :)

Fibers allocate memory using mmap or VirtualAlloc, so assuming a number 
of fibers are all allocated at the same time then their memory may well 
be contiguous.  But there isn't any explicit pooling of memory for 
fibers or anything like that.


Sean



More information about the Digitalmars-d-announce mailing list