Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Why 'Graphics.wait_next_event' doesn't reply anymore ?
Date: Tue, 13 Nov 2007 11:14:32 +0100	[thread overview]
Message-ID: <1194948872.473979088166f@webmail.in-berlin.de> (raw)
In-Reply-To: <20071113084547.2214223f@localhost.localdomain>

Hi,


Zitat von Fabrice Marchant <fabrice.marchant@orange.fr>:

> > Both threads use the Graphics-module (via View-module).
> > Possibly the problem is, that the access
> > is not protected: use Mutexes, when calling the View.<function>,
> > so that each Thread only has access to the View-functions
> > (and the Graphics module's functions), when the other thread
> > is ready with it's work. Otherwise possibly things become confused.
> >
> > So, wrap each of the View.<function> calls with
> > calls to Mutex.lock and Mutex.unlock.
> >
> > Possibly this is your main problem!
>
>   Great ! Oliver, it was this. All perfectly rocks at full speed now.

Heheh, fine.
So, it was not OCaml nor the Graphics module that is buggy ;-)


> I'm very happy my Game of Life finally works.

Are the new sources online?
How to play it?
Now that it works, I may play around with it for a while.... :)




> However, I've not understood why this Mutex was needed : what could be
> the data shared with 'wait_next_event' ?
>   Some internal of Graphics module ?

Yes, Graphics modules internals.
Both threads might share a lot of data.
They are drawing at the same screen,
so if their work might be interrupted by the
scheduler before the data was written completely,
something might go wrong.

If you can't be sure that the data is isolated,
use Mutexes. And in the case of the Graphics-module you
don't get back a value that holds something,
e.g. when using the initialization functions.
So seemingly they all write on the same data.
(And to have a copy of the whole screen always,
 would be wasting memory, so I think it's ok this way.)

One could write a wrapper-lib for it, so that
the Mutex-stuff is already inside then.
But that is something that should be up to the
users of the Graphics-module (and not the OCaml-team),
because needs and design might be differing a lot.
If people for example would not want to have Threads inside,
with such a wrapper-lib they would be inside nevertheless.
And that's, how bloat-projects start to evolve. ;-)


Ciao,
   Oliver


  reply	other threads:[~2007-11-13 10:14 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
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 [this message]
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=1194948872.473979088166f@webmail.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --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