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=1.2 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 850D6BC69 for ; Tue, 18 Dec 2007 06:18:41 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABPnZkfRVYT5kmdsb2JhbACQBAIBAQcEBCmaCA X-IronPort-AV: E=Sophos;i="4.24,178,1196636400"; d="scan'208";a="20444497" Received: from an-out-0708.google.com ([209.85.132.249]) by mail4-smtp-sop.national.inria.fr with ESMTP; 18 Dec 2007 06:18:40 +0100 Received: by an-out-0708.google.com with SMTP id b15so700384ana.102 for ; Mon, 17 Dec 2007 21:18:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; bh=ACfzWsCNRdleigjpvImq1/pIoIZ/Q/WMVls8ML1aOdk=; b=VPFoCriJIhGFAHezD88Qy9hUw/hN0bD5u/RLFKdyD1LVuu0hdX1Wb3XqZDACXrjL8Oa12VQveKGL7JKMPauLAH4OgCgm9/HrkFmcmC0rE6AqzIc6RZzCa0gM6QqB4IaPmsFKaTM/JUpQs49gErT7Kw4phuvyQ+KjGttuBf+E1Ss= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=nzGxo+OeDx5a14UfjoHkyw8P3LIKufVSQDxmKTritinVehr4Cl+dMYbKKKVe9txhQtsFxKPVawpnpdglqdiM7S9C345JPZyfB9AYewv8QCAJET2YnQ60S/e8xFZB45lBr9W0nLY6WkvRxjtN4PudhkgeRMiYUliN9ZMa/F1ff0Y= Received: by 10.100.255.10 with SMTP id c10mr16507952ani.54.1197955119595; Mon, 17 Dec 2007 21:18:39 -0800 (PST) Received: from ?192.168.0.7? ( [70.243.153.55]) by mx.google.com with ESMTPS id i49sm16497710rne.2007.12.17.21.18.37 (version=SSLv3 cipher=RC4-MD5); Mon, 17 Dec 2007 21:18:38 -0800 (PST) Message-ID: <4767582A.6020202@gmail.com> Date: Mon, 17 Dec 2007 23:18:34 -0600 From: Edgar Friendly User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: caml-list Subject: Problems spawning threads Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 argv:01 compilation:01 usr:01 ocamlopt:01 -thread:01 -noassert:01 -unsafe:01 usr:01 lib:01 ocaml:01 contrib:01 cmxa:01 cmxa:01 ocamlc:01 I've gone over the Computer Language Benchmarks Game[1] problems, and I can't figure out how help the administrators of this problem to get the OCaml code for the thread-ring benchmark (contributed by Charles Martin) to work on their computer. Here's the code: let size = 503 let n = int_of_string Sys.argv.(1) let run id ichan ochan = let rec loop () = let token = Event.sync (Event.receive ichan) in if token = n then (print_int id; print_newline (); exit 0) else (Event.sync (Event.send ochan (token + 1)); loop ()) in Thread.create loop () let () = let channels = Array.init size (fun _ -> Event.new_channel ()) in let threads = Array.init size (fun i -> run (i + 1) channels.(i) channels.((i + 1) mod size)) in Event.sync (Event.send channels.(0) 0); Thread.join threads.(0) Here's the compilation and execution: ~/tmp/testzone $ /usr/bin/ocamlopt -thread -noassert -unsafe -I /usr/lib/ocaml/contrib -ccopt -O3 -ccopt -fomit-frame-pointer -ccopt -march=pentium4 unix.cmxa threads.cmxa threadring.ml -o threadring.ocaml_run ~/tmp/testzone $ ./threadring.ocaml_run 100 Fatal error: exception Sys_error("Thread.create: Cannot allocate memory") The code runs fine when compiled with ocamlc -vmthread .... It works fine on my Athlon with the same compilation options (except for -march=athlon-tbird). Interestingly enough, the administrator reports that the code works with size=16, but fails for size=17. Any ideas what's going on or how to fix it? Hopefully I'll have some confirmation soon that the (probably useless) ccopts and other optimization options don't affect the error. We also checked ulimit settings - his max user processes and stack size are both higher than mine. (-u 4095, -s 160000k) Any other ulimit options that could interfere? Last piece of information: his box runs Gentoo Linux. E.