caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Wang <philippe.wang.lists@gmail.com>
To: Gregory Malecha <gmalecha@gmail.com>
Cc: Caml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Threads Scheduling
Date: Wed, 14 Apr 2010 10:40:51 +0200	[thread overview]
Message-ID: <q2q4d1b2df21004140140k7da15b46u21ccd7357d55e740@mail.gmail.com> (raw)
In-Reply-To: <k2o6d110d191004131456va1797d2bkfd72ee65dbfb6679@mail.gmail.com>

On Tue, Apr 13, 2010 at 11:56 PM, Gregory Malecha <gmalecha@gmail.com> wrote:
> Hi Jake,
> The documentation for Condition.wait says:
> wait c m atomically unlocks the mutex m and suspends the calling process on
> the condition variable c. The process will restart after the condition
> variable c has been signalled. The mutex m is locked again before wait
> returns.
> I figured that I needed to lock and unlock the mutex in the child threads
> because otherwise it is possible for the condition variable to be signaled
> before the main thread waits, which I thought means that the signal is
> lost.
> Thanks Daniel, I'll take a look at it.
> On Tue, Apr 13, 2010 at 5:04 PM, Daniel Bünzli <daniel.buenzli@erratique.ch>
> wrote:
>>
>> You may also be interested in this thread [1].
>>
>> Daniel
>>
>> [1]
>> http://groups.google.com/group/fa.caml/browse_thread/thread/9606b618dab79fb5
>
>
>
> --
> gregory malecha

Hi,

Your f function *might* prevent preemption...
For instance, if
let f () = while true do () done;;
then it means f does not allocate nor call any external function, and
so it the scheduler is stuck because scheduling is done at allocation
or *some* external functions (which contain "blocking sections", e.g.,
I/O operations).
So it is important that when using Thread module, there is, for
scheduling, at some point a call to an allocation or a "blocking"
operation, or Thread.yield.
As most functional code will allocate, this problem is not so frequent, though.



-- 
Philippe Wang
   mail@philippewang.info


  reply	other threads:[~2010-04-14  8:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-13 20:33 Gregory Malecha
2010-04-13 20:54 ` [Caml-list] " Jake Donham
2010-04-13 21:04 ` Daniel Bünzli
2010-04-13 21:56   ` Gregory Malecha
2010-04-14  8:40     ` Philippe Wang [this message]
2010-04-14 18:18       ` Goswin von Brederlow

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=q2q4d1b2df21004140140k7da15b46u21ccd7357d55e740@mail.gmail.com \
    --to=philippe.wang.lists@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=gmalecha@gmail.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).