Fibers

Bill Baxter wbaxter at gmail.com
Wed Oct 22 14:08:49 PDT 2008


On Thu, Oct 23, 2008 at 3:52 AM, Sean Kelly <sean at invisibleduck.org> wrote:
> Don wrote
>>
>> OT: When I first read about fibers (in Microsoft docs) I found the
>> terminology terribly confusing. Until I realized that "fiber" was the US
>> spelling of "fibre", at which point the connection with threads became
>> understandable. I still don't like the name, since OS threads aren't really
>> made of "fibers". You're just switching stacks. One aspect of implementing
>> threads is switching stacks. And that's the extent of the relationship, as
>> far as I can tell.
>
> I think the analogy fits in that a thread is made up of one or more fibers.
>  The term "StackThread" didn't workfor me because all threads have a stack.
>  I considered "ThreadContext" as well, but finally decided that "context"
> may be too loaded a term in this context (no pun intended).

I don't have a problem with the name Fibers for this, I just get this
feeling I've heard the term used somewhere to mean a lightweight
hardware thread.  But I could be wrong.

Wikipedia seems to agree with the terminiology though:
"""
In this article, the term "thread" is used to refer to kernel threads,
whereas "fiber" is used to refer to user threads. Fibers are
cooperatively scheduled: a running fiber must explicitly "yield" to
allow another fiber to run. A fiber can be scheduled to run in any
thread in the same process.
"""
      --- http://en.wikipedia.org/wiki/Multi-threading

And here:
"""
Like threads, fibers share address space; where a distinction exists,
it is that fibers use co-operative multitasking while threads use
pre-emptive multitasking. Threads often depend on the kernel's thread
scheduler to preempt a busy thread and resume another thread; fibers
yield themselves to run another fiber while executing.
"""
    ---- http://en.wikipedia.org/wiki/Fiber_(computer_science)

And finally MS agrees with the terminology. The Windows API calls em Fibers too:
http://msdn.microsoft.com/en-us/library/ms682661.aspx

So it seems there's a fair amount of agreement out there about what to
call these things.  More than I initially realized.

--bb



More information about the Digitalmars-d mailing list