caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: malc <malc@pulsesoft.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Usage of condition variables
Date: Thu, 17 Aug 2006 17:41:00 +1000	[thread overview]
Message-ID: <1155800460.5852.27.camel@rosella.wigram> (raw)
In-Reply-To: <Pine.LNX.4.64.0608170749530.631@home.oyster.ru>

On Thu, 2006-08-17 at 08:05 +0400, malc wrote:

> <quote>
> The pthread_cond_broadcast() or pthread_cond_signal() functions may be
> called by a thread whether or not it currently owns the mutex that threads
> calling pthread_cond_wait() or pthread_cond_timedwait() have associated
> with the condition variable during their waits; however, if predictable
> scheduling behavior is required, then that mutex shall be locked by the
> thread calling pthread_cond_broadcast() or pthread_cond_signal().
> </quote>
> 
> However it seems like members of OCaml team strongly prefer unlock
> then signal pattern.

When something is predictable, there is often a loss of efficiency
compared to a more indeterminate option.

In this case I'd guess that mutex lock/unlock triggers
a scheduling operation because synchronisation is required
anyhow. If there are multiple signallers it may be more
efficient to delay long enough for the signals to be
collated, and fire off the condition check only once.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2006-08-18  3:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-17  4:05 malc
2006-08-17  7:41 ` skaller [this message]
2006-08-17 11:55 ` [Caml-list] " Xavier Leroy

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=1155800460.5852.27.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=malc@pulsesoft.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).