W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2008

[whatwg] WebWorkers vs. Threads

From: David Jones <drj@ravenbrook.com>
Date: Tue, 12 Aug 2008 09:03:37 +0100
Message-ID: <AC6911EA-CC0F-4874-8160-DF8229621281@ravenbrook.com>

On 11 Aug 2008, at 18:43, Aaron Boodman wrote:

> On Sun, Aug 10, 2008 at 5:54 PM, Shannon <shannon at arc.net.au> wrote:
>> * each coroutine gets a real OS thread (if available).
> <snip>
> Coroutines in Lua are not operating system threads or processes.
> Coroutines are blocks of Lua code which are created within Lua, and
> have their own flow of control like threads. Only one coroutine ever
> runs at a time, and it runs until it activates another coroutine, or
> yields (returns to the coroutine that invoked it). Coroutines are a
> way to express multiple cooperating threads of control in a convenient
> and natural way, but do not execute in parallel, and thus gain no
> performance benefit from multiple CPU's. However, since coroutines
> switch much faster than operating system threads and do not typically
> require complex and sometimes expensive locking mechanisms, using
> coroutines is typically faster than the equivalent program using full
> OS threads.
> </snip>
> --http://lua-users.org/wiki/CoroutinesTutorial
> Is this description incorrect? It seems at odds with what you said
> about Lua coroutines getting an OS thread (if one is available).

The description you quoted from lua-users.org is correct.  The  
primary implementation of Lua is 100% portable ISO C, it therefore  
does _not_ use OS threads for coroutines.  I think there may be  
extensions/modifications produced by other parties that provide that.

David Jones
Ravenbrook Limited
Received on Tuesday, 12 August 2008 01:03:37 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:04 UTC