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=2.6 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr 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 83A75BBAF for ; Sat, 27 Jun 2009 12:39:54 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYCAN+TRUrRVdzemGdsb2JhbACYPz8BAQEBAQgJDAcTo1uBGY9lAQMCBIQJBQ X-IronPort-AV: E=Sophos;i="4.42,300,1243807200"; d="scan'208";a="42528479" Received: from mail-fx0-f222.google.com ([209.85.220.222]) by mail4-smtp-sop.national.inria.fr with ESMTP; 27 Jun 2009 12:39:54 +0200 Received: by fxm22 with SMTP id 22so2869386fxm.9 for ; Sat, 27 Jun 2009 03:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=w1yHEOM33oOGU3QMoc9Lxm/5TRPZ9YgI6BwGpsDYrw4=; b=nyr5roqGepvc+4xrRAdoWJCs6rJMQ2J9KWXxsZxCD2JR6cxyOldevO8/M8ilEV67Dy HUjFZuRSO5oMwhedONx2TNGQn8+VGZMopHWDSsZQyK/cj47mjNuuIKC6f9L1WLQa3ao2 BguFW9G8D23UGrRYN7HrIZGtAJXhW01a1Bcoc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=iI3ETN2Ne5Q7aS7Z36ngNy9J6KT+mbarjqji/mx75Pi3hXIeun8CBiDWpUj/zFh7lY +3VqHv2o1h846NkdklbvXoKQ6AbhtK0kmRRIVT0gsx+6A80s0AXeoQquQCkv1hpdpBdd Q7VKfZPwenrA30xKYTv8sX0FKU5Moc8IIpc7E= MIME-Version: 1.0 Received: by 10.223.103.194 with SMTP id l2mr3592764fao.55.1246099193675; Sat, 27 Jun 2009 03:39:53 -0700 (PDT) Date: Sat, 27 Jun 2009 12:39:53 +0200 Message-ID: <906164100906270339j3af90566ta6545d3086449219@mail.gmail.com> Subject: [Caml-list] Threads - how it actually works? From: =?ISO-8859-2?Q?Micha=B3_Maciejewski?= To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; michal:01 ocaml:01 looped:01 ocaml:01 lights:98 10.:98 threads:01 threads:01 unix:01 graph:01 graph:01 caml-list:01 caml:02 implemented:02 objects:02 Hi, Some time ago I had some problems with threads. I had to make a traffic lights simulation with cars as a academic project. I decided to write it using ocaml with graph module and threads for timing (since thread pausing didn't work in the same thread that the graph module worked). If I remember correctly there was a loop in graph module thread that was drawing some objects. Another looped thread was changing objects positions and then was paused for some amount of time using (I think) Unix module. I know that wasn't a good and optimal way to do it, but I had only few days for it. Now the problem was that one of those thread never worked. It looked like a graph thread was using whole cpu time, and there was no context switching. Don't ask me to paste any code, because I dont have it. It was quite long time ago and I had to do my project without timing. :-) It was ocaml 10.*. So how threads are actually implemented in caml? Using some kind of timing or atomic operations? regards M