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.8 required=5.0 tests=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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id ED0F6BBAF for ; Thu, 10 Sep 2009 20:17:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An8BAAPfqEpIDtyei2dsb2JhbACSA4h8PwEBAQoLCgcRBbIagSqQRwEDAgQFhA8FgjaCDQ X-IronPort-AV: E=Sophos;i="4.44,365,1249250400"; d="scan'208";a="35834585" Received: from fg-out-1718.google.com ([72.14.220.158]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 Sep 2009 20:17:42 +0200 Received: by fg-out-1718.google.com with SMTP id e21so1687388fga.3 for ; Thu, 10 Sep 2009 11:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=xB5FXSlFUbHCPbdg9FTj6dBjzcUJzIcU9Yi8Jjn7fWw=; b=uOvLsRiFL37Pi0TPIj0u03HyNR/I4e3HqwYywhtMfSO9qK+yNMutLJy9K9cLPqf0XX BkK0Z3r5cFoHVbfJf6PgbsAcBclCCuC3kgkaoTcotRHkCkzpVZ3z9Xahr8KMTl7XA4ms yPpPNmT3Ft5y72vtKZT64VMZPailr4EN59b9k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=d4ud0XrmySXDfdPVLrUz1qW7lxF2uQZg+zBRMtXzvNY3DBJLnNCX1G4h45dVjdfZGt sfOQvxKtNUzEKvwqhu9wYP+QAOgTUhFb8FVFSK6jpMR2GsUd5ItRRBx2SEfxtUuqrp23 dkRe+aAI3I+TfLkzcA/yCOQwYgTG3fQ+B8XXo= Received: by 10.86.209.23 with SMTP id h23mr1465779fgg.22.1252606661413; Thu, 10 Sep 2009 11:17:41 -0700 (PDT) Received: from lemon (101-101-132-95.pool.ukrtel.net [95.132.101.101]) by mx.google.com with ESMTPS id l19sm19506fgb.27.2009.09.10.11.17.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 10 Sep 2009 11:17:40 -0700 (PDT) Date: Thu, 10 Sep 2009 21:17:34 +0300 From: ygrek To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] threads Message-Id: <20090910211734.e959be39.ygrekheretix@gmail.com> In-Reply-To: <4d1b2df20909081620r55accbc1q837dd78317a7923f@mail.gmail.com> References: <20090908203319.cf4b1ff6.ygrekheretix@gmail.com> <4d1b2df20909081620r55accbc1q837dd78317a7923f@mail.gmail.com> X-Mailer: Sylpheed 2.5.0 (GTK+ 2.12.12; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="PGP-SHA1"; boundary="Signature=_Thu__10_Sep_2009_21_17_34_+0300_DAYuxwiRhJzJySDc" X-Spam: no; 0.00; scheduler:01 compiler:01 ocamlopt:01 2009:98 threads:01 garbage:01 wrote:01 caml-list:01 reorder:01 mutex:03 let:03 let:03 problem:05 sep:06 thread:06 X-Attachments: type="application/pgp-signature" --Signature=_Thu__10_Sep_2009_21_17_34_+0300_DAYuxwiRhJzJySDc Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, 9 Sep 2009 01:20:06 +0200 Philippe Wang wrote: > > let x =3D Array.make 100 [] > > let update i n =3D x.(i) <- n :: x.(i) > > let read i =3D x.(i) >=20 > I don't think you can obtain funny results when you don't put a mutex > on these two specific "update" and "read". > What is sure is that "update" function is not atomic because you have > a value allocation at the right of "<-" (with :: operator), and this > may trigger garbage collection and/or make the scheduler change the > running thread. Yes, that's not a problem. Thinking that over again it looks like the only issue remaining is the possibility that compiler can be too smart and cache/reorder memory operations, but ocamlopt is not of that kind, right? --=20 ygrek http://ygrek.org.ua --Signature=_Thu__10_Sep_2009_21_17_34_+0300_DAYuxwiRhJzJySDc Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkqpQr4ACgkQY0a5RXCNWgz5CgCg/tG4SAk9IJc7QCjS4oklDXb5 4KwAn1f47vCfCN1psxCHoJTclwlQEJIS =jdVe -----END PGP SIGNATURE----- --Signature=_Thu__10_Sep_2009_21_17_34_+0300_DAYuxwiRhJzJySDc--