Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Request: matrix_init function in Array
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-02-19 (17:36)
From: Brian Hurt <brian.hurt@q...>
Subject: Re: [Caml-list] Re: feature priorities (multithreading)
On Wed, 19 Feb 2003, Ranjan Bagchi wrote:

> I've been reading LtU lately ( and
> came across this paper:
> detailing a
> high-performance web-server written in Erlang.
> One point here is that the threads in Erlang uses a
> ton of "microthreads" which don't use OS Threads at
> all (and don't incur the overhead).  Stackless python
> ( does this too, and is able to
> support massive concurrency.

Yep.  These are called "userspace" or "green" threads.  They're fairly 
easy to do- all you have to do is swap stacks.  Some experimentation on my 
part showed that on a P4, you could task switch between two such user 
space threads in 30-60 clock cycles on the x86- less expensive than a 
cache miss.

User space threads have some problems.  First off, they don't take 
advantage of multiple CPUs, or SMT CPUs.  Second, and more importantly, if 
one thread blocks- either by doing blocking I/O, or page faulting- all 
threads block.

A better approach is what's called the M-by-N approach.  You have M kernel 
level threads (so you can take advantage of M parallel CPUs) each 
executing threads from a pool of N user space threads.  This gives you the 
best of both worlds.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: