
[1] Extending the Haskell Foreign Function Interface with Concurrency [2] Haskell on a Shared-Memory Multiprocessor I read the above two papers [1,2] and I have been trying to write an application that uses both FFI and SMP. The first paper [1] shows how FFI is implemented on uniprocessor concurrent Haskell; the second paper [2] shows how SMP Concurrent Haskell is implemented. However, I found little documentation on using FFI with the latest SMP extension. In addition to [1], what has been changed and what should a programmer know if he wants to use FFI in a multithreaded program running on SMP machines? Best, Peng

Li, Peng wrote:
[1] Extending the Haskell Foreign Function Interface with Concurrency [2] Haskell on a Shared-Memory Multiprocessor
I read the above two papers [1,2] and I have been trying to write an application that uses both FFI and SMP. The first paper [1] shows how FFI is implemented on uniprocessor concurrent Haskell; the second paper [2] shows how SMP Concurrent Haskell is implemented. However, I found little documentation on using FFI with the latest SMP extension. In addition to [1], what has been changed and what should a programmer know if he wants to use FFI in a multithreaded program running on SMP machines?
Nothing has changed relative to [1], the semantics is exactly the same. (and in case this wasn't clear, GHC's -threaded option implements the semantics in [1]). You should know that your "safe" FFI calls may be executed concurrently by separate OS threads, so calls you make in this way should be to thread-safe libraries. I'm looking into the bug you submitted, #713. It appears to be a bug in the runtime somewhere, but it's a difficult one to track down. Hopefully I'll have a fix soon. Cheers, Simon
participants (2)
-
Li, Peng
-
Simon Marlow