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] gc question: thread stacks, fibers, etc.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Hecker <checker@d...>
Subject: Re: [Caml-list] gc question: thread stacks, fibers, etc.

>>In C, you implement them by mallocing a stack and with a little snippet 
>>of asm, or mucking with the jmpbuf fields.  They're pretty trivial to get 
>>working fairly robustly
>.. and fairly useless in most demanding applications due to the
>impossibility of dynamically extending/shrinking the stack.
>If that isn't a problem .. you might as well just use
>real threads ..

Hmm, not sure I understand the last sentence there.

If you care about not having a fixed stack, you can handle it in the same 
way a thread handles its stack if you're willing to write os-dependent code 
(set guard pages, catch exceptions, etc.).  In ocaml, you can probably 
realloc in a non-os-dependent way fairly effectively, because you've got 
all the stack frames around in the frame tables and there are no pointers 
into the stack (well, except if you've called C functions in the middle...hmm).

Ignoring that, one reason you want fibers instead of threads is that you 
don't want preemption for some problems because it complicates your code to 
handle the asynchrony.  If you're saying you should just use non-preemtive 
threads (or make them non-preemptive with mutexes), well that's what I'm 
calling fibers.


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