caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: Alex Baretta <alex@barettadeit.com>
Cc: Ocaml <caml-list@inria.fr>, Luca Pascali <luca@barettadeit.com>
Subject: Re: [Caml-list] Mutex and posix
Date: Tue, 18 Jan 2005 21:31:56 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0501182130200.5563-100000@localhost.localdomain> (raw)
In-Reply-To: <41EB7CC4.30204@barettadeit.com>

On Mon, 17 Jan 2005, Alex Baretta wrote:

> > 
> > 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
> 
> I am aware of this. But, if one really needs the timed primitive, one 
> can always simulate it by sampling the mutex state repeatedly with 
> _trylock. Unix.select serves the purpose of controlling the sampling time.
> 
> Notwithstanding this, when the need arises for a timed primitive in a 
> concurrent algorithm, my suggestion is always to attempt to remodel the 
> problem rather than the API.

Um, no.  What happens if the mutex is unlocked for some period of time 
between your polls, but relocked before you poll the lock again?  It's 
very easy to hit livelock conditions doing this.

Brian



  reply	other threads:[~2005-01-19  3:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-12 10:53 Luca Pascali
2005-01-12 15:56 ` [Caml-list] " Xavier Leroy
2005-01-12 17:29   ` Luca Pascali
2005-01-15 17:53     ` Alex Baretta
2005-01-15 17:49 ` Alex Baretta
2005-01-15 19:37   ` Brian Hurt
2005-01-17  8:52     ` Alex Baretta
2005-01-19  3:31       ` Brian Hurt [this message]
2005-01-19  9:34         ` Alex Baretta
2005-01-17 12:33   ` Luca Pascali

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0501182130200.5563-100000@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=alex@barettadeit.com \
    --cc=caml-list@inria.fr \
    --cc=luca@barettadeit.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).