Version française
Home     About     Download     Resources     Contact us    
Browse thread
CallCC using fork (and garbage collected processes)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] CallCC using fork (and garbage collected processes)
On Mon, Jul 16, 2007 at 04:07:23PM +1000, skaller wrote:
> A much reduced version of this idea has been tried
> in C, swapping the C stack pointer and registers using
> setjmp/longjmp and some assembler.

It's even easier to use makecontext(3) et al, if you have them.  I
wrote a C implementation which tries a variety of strategies
(makecontext, setjmp, assembly), here:
http://annexia.org/freeware/pthrlib

> This is, of course, much faster than forking.
> 
> However the C method doesn't work, because Unix uses
> linear bounded stacks, and there isn't enough address 
> space to create enough stacks.

This is more of a problem with 32 bit machines.  64 bit machines
shouldn't have an issue.  Even on a 32 bit machine I could get
thousands of threads before hitting a limit.

Rich.

-- 
Richard Jones
Red Hat