What is the difference between a thread and a fiber?

前端 未结 9 910
北荒
北荒 2020-12-07 07:28

What is the difference between a thread and a fiber? I\'ve heard of fibers from ruby and I\'ve read heard they\'re available in other languages, could somebody explain to me

9条回答
  •  暖寄归人
    2020-12-07 08:02

    Win32 fiber definition is in fact "Green Thread" definition established at Sun Microsystems. There is no need to waste the term fiber on the thread of some kind, i.e., a thread executing in user space under user code/thread-library control.

    To clarify the argument look at the following comments:

    • With hyper-threading, multi-core CPU can accept multiple threads and distribute them one on each core.
    • Superscalar pipelined CPU accepts one thread for execution and uses Instruction Level Parallelism (ILP) to to run the the thread faster. We may assume that one thread is broken into parallel fibers running in parallel pipelines.
    • SMT CPU can accept multiple threads and brake them into instruction fibers for parallel execution on multiple pipelines, using pipelines more efficiently.

    We should assume that processes are made of threads and that threads should be made of fibers. With that logic in mind, using fibers for other sorts of threads is wrong.

提交回复
热议问题