From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id D12B6BCB0 for ; Sun, 12 Jun 2005 12:07:48 +0200 (CEST) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j5CA7lgV008903 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sun, 12 Jun 2005 12:07:48 +0200 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1DhPT1-00069E-00; Sun, 12 Jun 2005 11:13:23 +0100 Date: Sun, 12 Jun 2005 11:13:23 +0100 To: Jonathan Roewen Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Pre-emptive multitasking Message-ID: <20050612101323.GA21947@furbychan.cocan.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.28i From: Richard Jones X-Miltered: at nez-perce with ID 42AC0973.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 runtime:01 systhreads:01 thread-safe:01 ocaml:01 threads:01 threads:01 sockets:01 notepad:01 multitasking:98 multitasking:98 wrote:01 thread:02 pipes:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Sun, Jun 12, 2005 at 08:51:44AM +1200, Jonathan Roewen wrote: > Does the OCaml runtime support true pre-emptive multitasking with the > systhreads module? Am curious how this works with the GC without > breaking anything. The GC isn't thread-safe. This means that when OCaml code runs, it must be protected by a global mutex. If you have two threads running OCaml code, they will contend for this mutex, and run (around) 50% of the time each. If you have two CPUs you won't gain any benefit. The standard solution would be to run one OCaml thread and lots of C threads, or else use fork(2) to create one separate process for each processor and use shared memory, sockets, pipes, etc. for communication. Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com