lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

El 23/01/2005, a las 11:16, skaller escribió:

On Sun, 2005-01-23 at 19:59, Chris Pressey wrote:

I don't doubt coroutines complicate the programming model considerably. But I also don't see why coroutines should be necessary for scalability.

They're not: what's necessary is O(1) - O(log n) context
switching. Coroutines provide the possibility -- note,
its just a possibility -- of fast user space context switching.
This seems useful, considering OS switching usually has two
very bad negatives:

(a) its O(n)

Totally disagree. A «good enough» OS should have an O(1) scheduler, like the one present in Linux 2.6.x, NetBSD 2.0, and so on. Actually there's no practical reason to make a scheduler have O(n) complexity. For more info on the Linux 2.6 scheduler: features-scheduler.html

So context switching consists in:

1.) Running the scheduler to select a new task. A good scheduler should be O(1)!

2.) Moving the context of the active task out of the CPU. This involves saving CPU registers (which is O(1)), and removing the process' memory mapping from the MMU (which is O(1), too).

3.) Load the context of the selected task in the CPU. This again involves copying saved CPU registers and load a memory map in the MMU.

So we can conclude that task switching should be O(1)!

Adrian Perez
Keyboard Error: Press F1 to resume.

Attachment: PGP.sig
Description: Mensaje firmado digitalmente