> Is there a way of calling exported 'dynamic export' functions in a > thread-safe manner? I have this problem in JVM-Bridge... > > This is what the main thread does, from Haskell: > > 1. starts the Java VM, which starts a bunch of other threads, > including > the AWT thread; > 2. creates a pointer to a some IO function 'paint', using a 'dynamic > export' callback-maker; > 3. creates a new Java Frame (i.e. a GUI window) with the > function-pointer; > 4. repeatedly calls the Java Thread.yield function for 20 seconds. > (the program then ends) > > Now, once the Java Frame has been created, the AWT thread will > occasionally call the 'paint' method, which ends up calling the > function-pointer. However, it seems GHC 5.02 'dynamic export' > calls are > not thread-safe, and sooner or later it crashes, either with a seg > violation or a complaint about unknown closure types.
If you're talking about OS threads (eg. POSIX threads), then GHC's RTS certainly isn't thread safe. It isn't safe to call foreign exported functions from more that one OS thread simultaneously. We have some partially working thread support, but it has been on the back burner for some time now. Cheers, Simon _______________________________________________ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users