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 NAA05420; Thu, 20 Nov 2003 13:49:52 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA05655 for ; Thu, 20 Nov 2003 13:49:51 +0100 (MET) Received: from bourg.inria.fr (bourg.inria.fr [128.93.11.100]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hAKCno102484 for ; Thu, 20 Nov 2003 13:49:50 +0100 (MET) Received: from starynke by bourg.inria.fr with local (Exim 4.24) id 1AMoFq-0002Eb-28; Thu, 20 Nov 2003 13:49:50 +0100 Date: Thu, 20 Nov 2003 13:49:50 +0100 To: erayo@cs.bilkent.edu.tr Cc: caml-list@inria.fr Subject: Re: [Caml-list] Need advice for a mobile application server Message-ID: <20031120124949.GA8495@bourg.inria.fr> References: <200311192003.37039.exa@kablonet.com.tr> <20031120091315.GA23449@redhat.com> <20031120102727.A28533@pauillac.inria.fr> <200311201408.06069.exa@kablonet.com.tr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200311201408.06069.exa@kablonet.com.tr> User-Agent: Mutt/1.5.4i From: Basile Starynkevitch X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 basile:01 basile:01 eray:01 ozkural:01 eray:01 threads:01 threads:01 generational:01 devil:01 posix:01 poesia:01 closures:01 passing:01 unixqueue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Nov 20, 2003 at 02:08:06PM +0200, Eray Ozkural wrote: Eray> On Thursday 20 November 2003 11:27, Xavier Leroy wrote: [...] Xavier>> Back to the original question: writing a multithreaded server in OCaml Xavier>> is definitely feasible. The only limitation to be aware of is that Xavier>> OCaml threads do not offer parallelism, just concurrent execution. Xavier>> What this means is that if there are several processors on your Xavier>> machine, only one can execute OCaml code at any time, but other Xavier>> threads (and therefore possibly other processors) can do I/O or C Xavier>> computations in parallel. Eray> I couldn't quite figure out why only one proc. can execute ocaml Eray> code yet, but I can dig into the documentation :) Mostly, because of the garbage collector. The Ocaml GC is very efficient, and writing a generational [half-] copying *multi-threaded* GC is quite difficult (as usual, the devil is in the details). Actually, coding an efficient multithreaded GC with write barriers using Posix threads is very tricky (if not impossible, notably for synchronising minor GCs on every thread.) - for example you'll probably need to access thread local storage on each allocation, which (in portable C code) means calling pthread_getspecific every time. Regarding multi-threading in Ocaml, I think that it is much less useful in Ocaml than say in Java or C. In my experience (on my previous job) I started to code a multi-threaded application (the POESIA monitor), and prefered to switch to a single-threaded design, taking into advantage the functional abilities of Ocaml (i.e. mentally replacing threads by sets of small correlated tasks, each represented as functional values, ie closures, which means coding in a continuation passing style). For instance the Unixqueue library (from the Equeue software, used with Netclient) is single-threaded but very useful to handle several "concurrent" communication channels -e.g. HTTP or RSH connections. Regards. -- Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr Project cristal.inria.fr - phone +33 1 3963 5197 - mobile 6 8501 2359 http://cristal.inria.fr/~starynke --- all opinions are only mine ------------------- 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