From: Fabrice Marchant <fabrice.marchant@orange.fr>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Why 'Graphics.wait_next_event' doesn't reply anymore ?
Date: Sun, 11 Nov 2007 21:13:18 +0100 [thread overview]
Message-ID: <20071111211318.375f2ed7@localhost.localdomain> (raw)
In-Reply-To: <20071111183530.GA19575@localhost>
Hi,
Thanks for the help !
On Sun, 11 Nov 2007 19:35:30 +0100
Julien Moutinho <julien.moutinho@gmail.com> wrote:
> On Sun, Nov 11, 2007 at 05:48:34PM +0100, Oliver Bandel wrote:
> > [...]
> > This code looks ugly.
> I've just noticed the id := Some (Thread.create run ())
> coupled with the [while !id <> None do] in run:
> it seems possible that the while loop never starts.
Oliver didn't spoke about my code...
Anyway these are not real codes but rather snippets intended to track the issues.
However what you say is right. I mentionned it in original post :
>>> There is no delay problem in changing thread 'id' after creation and process test '!id <> None' is soon true at first call.
> And the useless call to Thread.exit.
Indeed, I removed it in original post :
>>> let run () =
>>> while !id <> None do
>>> step (); (* Changes drawing state *)
>>> plot () (* ;
>>> Thread.delay 0.01 *)
>>> done
>>>
>>> let rec test () =
Should have updated blockIssue.ml source...
Thread.exit () (* <- Is it really useful, at end of thread code here ? *)
> But I think these are unrelated stuffs to the real matter:
> the thread running wait_next_event seems to never get
> the attention of the thread scheduler.
I agree.
> > Here is the code (I have tested it, and it works):
> Unfortunately, if I remove the calls to Printf/flush in code1,
> then the thread running wait_next_event still hangs up,
> I mean has no time to run as in Fabrice's code (without the call
> to Thread.delay).
I thought it was a time question too. But I performed some trials and
now doubt of this.
>
> I tried to replace Printf/flush calls by a simple call to:
> CAMLprim value
> release_master_lock (value unit)
> {
> enter_blocking_section();
> leave_blocking_section();
> return Val_unit;
> }
> and I observed that the thread running wait_next_event
> does not hang up, as with the Printf/flush calls.
>
> Hence, I think it's only because Printf/flush release the master
> lock when they try to lock the mutex of stdout, that your proposal
> works better.
> Fabrice: I would expect Thread.yield to help in such situation,
> but I am unable to get something out of it.
I tried to put some 'yields' at different locations of the code,
just like Berke Durak did. Unfortunately they didn't change the
program behaviour.
I'm grateful for the interesting results of the trials you exposed
here.
Regards,
Fabrice
next prev parent reply other threads:[~2007-11-11 21:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-10 22:01 Fabrice Marchant
2007-11-11 14:07 ` [Caml-list] " Fabrice Marchant
2007-11-11 16:48 ` Oliver Bandel
2007-11-11 18:35 ` Julien Moutinho
2007-11-11 20:13 ` Fabrice Marchant [this message]
2007-11-12 0:33 ` Oliver Bandel
2007-11-11 19:40 ` Fabrice Marchant
2007-11-12 0:43 ` Oliver Bandel
2007-11-12 19:54 ` Fabrice Marchant
2007-11-12 21:18 ` Oliver Bandel
2007-11-13 7:45 ` Fabrice Marchant
2007-11-13 10:14 ` Oliver Bandel
2007-11-13 20:10 ` Fabrice Marchant
2007-11-14 0:33 ` Oliver Bandel
2007-11-12 0:46 ` Oliver Bandel
2007-11-12 6:18 ` Oliver Bandel
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=20071111211318.375f2ed7@localhost.localdomain \
--to=fabrice.marchant@orange.fr \
--cc=caml-list@yquem.inria.fr \
/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