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 HAA19601; Thu, 20 Nov 2003 07:35:14 +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 HAA23235 for ; Thu, 20 Nov 2003 07:35:12 +0100 (MET) Received: from mail3.tpgi.com.au (mail.tpgi.com.au [203.12.160.59]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hAK6ZA125575 for ; Thu, 20 Nov 2003 07:35:11 +0100 (MET) Received: from 203-213-85-204-syd-ts17-2600.tpgi.com.au (203-213-85-204-syd-ts17-2600.tpgi.com.au [203.213.85.204]) by mail3.tpgi.com.au (8.11.6/8.11.6) with ESMTP id hAK6Z1320016; Thu, 20 Nov 2003 17:35:02 +1100 Subject: Re: [Caml-list] Need advice for a mobile application server From: skaller Reply-To: skaller@ozemail.com.au To: erayo@cs.bilkent.edu.tr Cc: Caml Mailing List In-Reply-To: <200311192003.37039.exa@kablonet.com.tr> References: <200311192003.37039.exa@kablonet.com.tr> Content-Type: text/plain Message-Id: <1069306474.24578.76.camel@pelican> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 20 Nov 2003 16:34:35 +1100 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ozemail:01 eray:01 ozkural:01 feats:01 simulating:01 threads:01 threads:01 posix:01 violates:01 posix:01 abstractions:01 caveat:01 allocations:01 bindings:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 2003-11-20 at 05:03, Eray Ozkural wrote: > Hello there, > > I am looking to consider ocaml for writing a multi-threaded application server > which involves data structures of medium complexity (to be specific geometric > structures). Do you think ocaml is a good bet for this purpose, or should I > stick with C++? (in which I know how to write SMP code :) > > Will it be easy and efficient for me to implement imperative data structures > which should be locked on update ops, but will not need such on queries (yes, > I know it sounds naughty but it should be possible)? Or are there well known > obstacles to performing such feats using our beloved ocaml? Executive Summary [for lazy reader ..]: Use Ocaml. I have written some multi-threaded client/server and peer2peer Caml code for simulating a telephone network. For this purpose I used module Event which is very good (once you get the hang of it ..) To create servers I modified the source code of the Ocaml client/server function Unix.establish_server. This function creates processes rather than threads, and so I had to adapt it to threads which is quite easy. My code was all native code using Posix threads, it ran on both Linux and Solaris BUT be warned that at least at that time (several years ago now) Linux cannot create threads, only processes, and consequently all threads are detached. In the case of an error, the main thread can die but the other threads can keep running .. [this doesn't happen on Solaris and violates Posix, I don't know whether this is fixed yet in Linux .. in any case it has nothing to do with the choice of Ocaml ..] As usual I think Ocaml is superior *especially* for complex tasks where abstractions with strong guarrantees are highly desirable for reasoning about software. The only caveat I know of is that Ocaml sometimes uses global locks (the gc can't run concurrently with allocations etc) and if you create C bindings for Ocaml you have to be careful to make sure you manage the exclusion correctly or you might end up with a deadlock. ------------------- 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