From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6FBF4BB91 for ; Sat, 15 Jan 2005 20:35:49 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0FJZm6d026404 for ; Sat, 15 Jan 2005 20:35:49 +0100 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 UAA16386 for ; Sat, 15 Jan 2005 20:35:48 +0100 (MET) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0FJZkT7026392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 15 Jan 2005 20:35:48 +0100 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.13.1/8.13.1) with ESMTP id j0FJZbFY007835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 15 Jan 2005 13:35:40 -0600 (CST) Date: Sat, 15 Jan 2005 13:37:33 -0600 (CST) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Alex Baretta Cc: Luca Pascali , Subject: Re: [Caml-list] Mutex and posix In-Reply-To: <41E957C5.6050808@barettadeit.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 41E97094.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41E97092.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 posix:01 baretta:01 wrote:01 wrote:01 posix:01 mutexes:01 const:01 struct:01 simulate:01 waits:01 waits:01 unix:01 functions:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Sat, 15 Jan 2005, Alex Baretta wrote: > Luca Pascali wrote: > > Just a little question, my curiosity about the thread module. > > > > I found in Posix (this is from 'info libc' page on section Mutexes) > > these three functions > > > > Function: int pthread_mutex_lock (pthread_mutex_t *mutex)) > > Function: int pthread_mutex_trylock (pthread_mutex_t *MUTEX) > > Function: int pthread_mutex_timedlock (pthread_mutex_t *MUTEX, const > > struct timespec *ABSTIME) > > You can probably simulate the third one fairly well by resorting to > Unix.select as a timer, but why in the world would you want to lock for > a while and then forget about it? No, you misunderstand what the function does. The function won't wait more than ABSTIME to acquire the lock. _mutex_lock() waits forever to get the lock, _mutex_trylock doesn't wait at all, and _mutex_timedlock only waits so long to get the lock. Brian