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
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-03-01 (17:06)
From: Christophe Raffalli <Christophe.Raffalli@u...>
Subject: GC + thread

The following extension for Ocaml GC seems to me simple and necessary (I
really do need it):

It considers only channels dans thread and I will describe it for a mark
and swip GC.

rule 1: a channel can be marked by the GC in two ways: read or write.
rule 2: a channel that is accssible by the GC in the usual way is both
marked read and write
        (usual means in a way no covered by rule 3).
rule 3: if a closure if blocked while trying to read from channel R_1,
..., R_n
                                         or to write from channel W_1,
..., W_n
        - the channels R_1,..,R_n are marked as read
        - the channels W_1,..,W_n are marked as write
        - the closure will be examined by the GC if and only if 
          one the channel R_i is marked write or one the channel W_i is
marked read
          if the condition is not immidiately true, the examination of
the closure is 
        - if no channel R_i are marked write and no channel W_i are
           read at the end of the mark pass, the closure and the
corresponding thread
          can be safely destroyed (the thread will never wake up).

So clearly this require only a modification of the GC of blocked thread
and needs to keep to extra bits for channels (this is not a big cost).

I would be good to also introduce mono-directional channel (the function
create return a pair with an in_channel and an out_channel). In this
case the GC ca be optimized to collect more threads in a trivial way
(when the GC reaches the in part of a channel it is only marked read and
if the GC reaches the out part of a channel it is only marked write).

This extension is also necessary (it is easy to have realistic examples
where the GC would collect much more thread with this extension).

What do you think of that ?
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42