From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B104CBC6B for ; Mon, 4 Jun 2007 18:54:29 +0200 (CEST) Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l54GsS1t021304 for ; Mon, 4 Jun 2007 18:54:29 +0200 Received: from [192.168.0.104] (12-208-242-210.client.mchsi.com[12.208.242.210]) by sccmmhc92.asp.att.net (sccmmhc92) with SMTP id <20070604165428m9200da2eme>; Mon, 4 Jun 2007 16:54:28 +0000 In-Reply-To: <9b415f950706040933r22e1560fhc088368ccb8444fa@mail.gmail.com> References: <200706041156.16521.jon@ffconsultancy.com> <67BC38F1-55DA-46F6-B35E-E728F7B1154B@valdosta.edu> <9b415f950706040850v586a285ax1448d23c0c78a375@mail.gmail.com> <1B7A6678-6C9E-4356-802C-5CA5168A27CC@valdosta.edu> <9b415f950706040933r22e1560fhc088368ccb8444fa@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <9BE9B524-35AA-43AC-8A63-4153E3AD672F@valdosta.edu> Cc: caml-list@yquem.inria.fr Content-Transfer-Encoding: 7bit From: Jonathan Bryant Subject: Re: [Caml-list] Faking concurrency using Unix forks and pipes (ray tracing results) Date: Mon, 4 Jun 2007 12:53:04 -0400 To: Benedikt Grundmann X-Mailer: Apple Mail (2.752.3) X-Miltered: at concorde with ID 466443C4.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; forks:01 grundmann:01 marshaled:01 ocaml:01 mutable:01 synchronous:01 mutable:01 commited:01 mli:01 struct:01 threads:01 cheers:01 2007,:98 calvin:98 calvin:98 On Jun 4, 2007, at 12:33 PM, Benedikt Grundmann wrote: > > It looks a bit more complex, but that's just to avoid big strings in > case of big messages > (e.g. with the "simple" interface you end up with the "same" content > in memory twice). I think big strings are unavoidable in this case. They can be broken up at the protocol level for sending, but a large data structure is going to be marshaled into a big string. As far as same content in memory twice, that should be the case for pure values even in a regular OCaml program. As for mutable values, they shouldn't be sent over a channel to begin with. Once channels are available though, creating a synchronous mutable cell is only a few lines of code. (Check out Reppy's book/papers). > I'm trying to do something similar, but I'm not 100% sure right now > that it will all work out exactly as I initially thought.. :-) You > can have a look at my current "interface", I already have a prototype > commited... src/mailbox.mli is the "main" interface of the library. > The comments are not totally in sync with the interface right now as > I'm restructuring a lot these days. I need to do a commit. I'm using modules which return a record of functions, and you can compose them to get channels that work over multiple mediums. > Okay I'm still a little bit confused how does your Thread.create looks > like (e.g what is > its signature)? Something like: module Thread = struct type con_type = | Concurrent | Parallel | Remote let create ?(con = Concurrent) f x = (* Create thread *) let concurrent f x = create ~con:Concurrent f x let parallel f x = create ~con:Parallel f x let remote f x = create ~con:Remote f x let create_attached ?(con = Concurrent) f x = (* Create thread and return event *) let concurrent_attached f x = create ~con:Concurrent f x let parallel_attached f x = create ~con:Parallel f x let remote_attached f x = create ~con:Remote f x (* Other thread functions *) end I've implemented a good chunk of channels/events so far, but haven't got to the threads yet, so don't quote me on that exact signature. --Jonathan > > Cheers, > > Bene > > -- > Calvin: I try to make everyone's day a little more > surreal. > > (From Calvin & Hobbes)