[HOpenGL] HOpenGL and --enable-threaded-rts

Simon Peyton-Jones simonpj@microsoft.com
Tue, 18 Jun 2002 16:27:39 +0100


Simon and I have discussed this multi-threading question a bit.
This message tries to summarise the story as we understand it.


GHC's approach to threading
~~~~~~~~~~~~~~~~~~~~
Make certain you read the "Supporting multi-threaded inter-operation"
section of the GHC commentary
=09
http://www.cse.unsw.edu.au/~chak/haskell/ghc/comm/rts-libs/multi-thread.
html


The current GHC model has the basic assumption that OS threads
are inter-changeable.  One Haskell thread may be executed by one
OS thread or by many; you just can't tell.

There is a good reason for this: the current OS thread may block
in some I/O call (getChar, say), and we don't want that to block=20
all Haskell threads.

If you want all Haskell threads executed by a single OS thread,
then you don't want --enable-threaded-rts, and your I/O calls may
block all Haskell threads.

There is no notion of a Haskell-thread-local location right now.
We don't know how to make it type-safe.  If you want that, you have
to define your own environment monad, which isn't too hard.  Or
use implicit parameters, also not hard.


GLUT's approach to threading
~~~~~~~~~~~~~~~~~~~~~
Simon and I don't understand GLUT's requirements at all clearly.
Why is the context thread-local?  Because different threads can have
different contexts?  Do you really need that?  If not, would it suffice
to
make all the threads have (a pointer to) the same context)?

Much the tidiest thing is to make the context an explicit parameter
to GLUT calls.  Or, if there is only one context of interest, keep it in
a process-global location (not thread-local) and, sigh, heave it into
the thread-local location before every GLUT call.


In short, we don't understand GLUT well enough to be able to
propose a solution.   I hope that the above remarks may help the
GLUT experts understand GHC well enough to write down a summary
of what is going on.  Try not to rely on someone having read all the
past mail!=20


Simon



| -----Original Message-----
| From: Sven Panne [mailto:Sven_Panne@BetaResearch.de]=20
| Sent: 18 June 2002 15:06
| To: hopengl@haskell.org
| Cc: GHC List
| Subject: Re: [HOpenGL] HOpenGL and --enable-threaded-rts
|=20
|=20
| Simon Marlow wrote:
| > [...] a given Haskell thread can even migrate from one OS thread to=20
| > another during its execution.
|=20
| Uh, oh!  %-(  Under which circumstances exactly? I fear this=20
| will give loads of fun with many C libraries out there, so=20
| it's important to know...
|=20
| Cheers,
|    S.
| _______________________________________________
| Glasgow-haskell-users mailing list=20
| Glasgow-haskell-users@haskell.org=20
| http://www.haskell.org/mailman/listinfo/glasgow-| haskell-users
|=20