From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA11882; Fri, 16 Apr 2004 18:15:20 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA11709 for ; Fri, 16 Apr 2004 18:15:19 +0200 (MET DST) Received: from [128.93.8.158] (macaque.inria.fr [128.93.8.158]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3GGGMjq016964 for ; Fri, 16 Apr 2004 18:16:22 +0200 Mime-Version: 1.0 (Apple Message framework v613) In-Reply-To: <407FB5BA.10607@univ-savoie.fr> References: <407FB5BA.10607@univ-savoie.fr> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <432746EE-8FC1-11D8-806C-00039310CAE8@inria.fr> Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] Thread in OCaml Date: Fri, 16 Apr 2004 18:15:22 +0200 To: caml-list@inria.fr X-Mailer: Apple Mail (2.613) X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 raffalli:01 threads:01 -thread:01 runtime:01 allocating:01 runtime:01 allocating:01 invalidates:01 pointers:01 read-only:01 threads:01 speedup:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Apr 16, 2004, at 12:30, Christophe Raffalli wrote: > 1) why the name enter(resp leaving)_blocking_section to release(resp > aquire) a mutex ? you aquire a mutex when you want to block other > threads. The name seems inversed to me and this did not help. As Daniel said, they are supposed to be placed before and after a piece of code that may call blocking system calls (like read, for example). > 2) is there a way to have two files wrap_glut.c one with > enter/leaing_blocking_section the other without (or MACROS), the right > file being used depending if the -thread or -vmthread option is given I think you're supposed to use them in all cases. If it doesn't work, I want to know about it. > 3) I know a little (not much) about the runtime system of OCaml and I > think (probably wrongly), that it would be enough to aquire a mutex > when allocating heap object (for this you need a list of grey-val for > each thread but it should not be difficult). What am I missing about > the runtime ? Allocating can call the GC, and the GC can move values around, which invalidates pointers. Even read-only access to the heap is impossible during the GC. > If you think a typical Caml program spend 20% of time during > allocation(which include GC) then 5 threads could run concurrently on > 5 CPUs with some speedup (up to 5 times in the best case). If only it was so easy to make a good concurrent GC... > Remark: for me it is to the programmer to add mutex if a mutable is > being written/read by more that one thread. Of course. The current Caml threads already make this assumption, since they are preemptive. -- Damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners