[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Single-threading servers and select()
- From: Adrián Pérez <copylight@...>
- Date: Sun, 23 Jan 2005 18:14:57 +0100
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
But I also don't see why coroutines should be necessary for
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:
So context switching consists in:
1.) Running the scheduler to select a new task. A good scheduler should
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)!
Keyboard Error: Press F1 to resume.
Description: Mensaje firmado digitalmente