Re: Summary so far (was: HOpenGL and --enable-threaded-rts)

2002-06-20 Thread Wolfgang Thaller
Simon Marlow wrote: This discussion is getting rather long, so I thought I'd summarise (as much for my benefit as everyone else's). Please let me know if I get anything wrong. I haven't found anything wrong. I'm pretty sure (1) and (2) aren't viable, though. I basically agree. In the presence (

Re: HOpenGL and --enable-threaded-rts

2002-06-19 Thread Wolfgang Thaller
On Mittwoch, Juni 19, 2002, at 01:43 , Andrew J Bromage wrote: > I don't mean to detract from the fine work which the HOpenGL people > have achieved, but I think that binding to the C implementation of GLUT > was, in retrospect, a mistake. The problem here is with OpenGL, not with GLUT. OpenGL r

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

2002-06-18 Thread Andrew J Bromage
G'day all. On Tue, Jun 18, 2002 at 05:58:15PM +0100, Alastair Reid wrote: > A further piece of what one might call thread local state is > 'recursive locks' like those found in Java. Recursive locks arguably should be part of the lock abstraction, not "thread local state ". Since all it costs

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

2002-06-18 Thread Wolfgang Thaller
I have implemented a hack that makes HOpenGL work with --enable-threaded-rts. It currently contains 3 lines of MacOS X-specific code, and it needs cleaning up. More about that later. > Simon and I don't understand GLUT's requirements at all clearly. > Why is the context thread-local? OpenGL

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

2002-06-18 Thread Alastair Reid
> Yes, these are all problems. However, there is a nice abstraction > of the OS thread API in GHC's RTS, thanks to Sigbjorn. So I'm sure > this API could be extended to include some thread-local state > operations. A further piece of what one might call thread local state is 'recursive locks'

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

2002-06-18 Thread Simon Peyton-Jones
t: 18 June 2002 15:06 | To: [EMAIL PROTECTED] | Cc: GHC List | Subject: Re: [HOpenGL] HOpenGL and --enable-threaded-rts | | | Simon Marlow wrote: | > [...] a given Haskell thread can even migrate from one OS thread to | > another during its execution. | | Uh, oh! %-( Under which circum

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

2002-06-18 Thread Glynn Clements
Simon Marlow wrote: > The trouble is that there isn't a single object representing the whole > thread-local state. Does OpenGL use pthread_getspecific() and > pthread_setspecific() to access its thread-local state? The libGL supplied with XFree86 uses xthread_{get,set}_specific. These are macr

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

2002-06-18 Thread Dean Herington
Let me ask a naive question concerning the implementation of threading in the GHC RTS. Would it be feasible to support an alternative strategy for mapping Haskell threads onto OS threads, namely that the two sets are kept in one-to-one correspondence? The thread multiplexing and migration that G

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

2002-06-18 Thread Sven Panne
Simon Marlow wrote: > [...] a given Haskell thread can even migrate from one OS thread to > another during its execution. Uh, oh! %-( Under which circumstances exactly? I fear this will give loads of fun with many C libraries out there, so it's important to know... Cheers, S. __

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

2002-06-18 Thread Simon Marlow
> I'm slowly losing track of this discussion... so am I :-( > My initial suggestion > was that it is guaranteed that the same OS thread which created the > f.i.w. thunk is used to call back to Haskell for *this* > wrapped function. > There is no overhead for calls Haskell->C, only for the compa

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

2002-06-18 Thread Sven Panne
I'm slowly losing track of this discussion... My initial suggestion was that it is guaranteed that the same OS thread which created the f.i.w. thunk is used to call back to Haskell for *this* wrapped function. There is no overhead for calls Haskell->C, only for the comparatively rare case of C->Ha

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

2002-06-18 Thread Simon Marlow
> This sounds like a lot of work and a porting nightmare (what do you > mean Linux/Win32/HPUX/... doesn't have thread manipulation function X, > it's available on FreeBSD/Win32/... What if there are other forms > of thread-local state (e.g., errno)? What about setjmp/longjmp?). Yes, these are

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

2002-06-18 Thread Alastair Reid
SimonM: > Yes, my guess is that this will probably have to be done by > manipulating the thread-local state in the RTS - grab the current > thread-local state whenever a call is made into Haskell, and > whenever we run a Haskell thread we have to set the appropriate > thread-local state. Perhaps

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

2002-06-18 Thread Simon Marlow
> Has anyone already thought about how to solve this problem? > I'm thinking about adding hooks to the RTS (in grabCapability, > releaseCapability and scheduleThread_) which would be used > for setting > up the correct thread-local state whenever Haskell execution > "switches" > to a differe

HOpenGL and --enable-threaded-rts

2002-06-16 Thread Wolfgang Thaller
In short, it doesn't work :-( . OpenGL (at least on MacOS) keeps track of the "current context" on a per-thread basis. The GLUT library sets the current context and calls back to the program. With GHC 5.03 compiled with --enable-threaded-rts, the callback gets executed in a different thread. Th