On 30 March 2006 22:01, Claus Reinke wrote: >>> the point being: the FFI says something about how to integrate >>> foreign and Haskell memory management; should it also say something >>> about threadability of foreign code (wrt to scheduling, and wrt >>> thread-safety)? >> If Haskell' includes concurrency then of course it must say something >> about the behaviour of foreign calls with respect to concurrency (if >> that's what you mean by "threadability"). Is that what you're >> asking? > > yes. I'm all for Haskell' having both ffi and concurrency, but that > means that the feature interactions have to be investigated. I know > you made a start on that, so I was just pointing out some further > corners that may need looking into: > > - if foreign code is used in Haskell' scheduling, what properties of > the foreign code need to be specified, how does long-running > foreign code interact with the scheduler, and are the current > annotations sufficient for all that? > > - if Haskell' code involving concurrency is foreign exported, what > does that mean? does it work out of the box, or what are the > limitations?
Rather than answer these directly, I'll point to this paper which addresses these questions and more: http://www.haskell.org/~simonmar/papers/conc-ffi.pdf GHC implements exactly what is in that paper. For Haskell', I expect we won't require all of it, some will be relegated to extensions. > I was looking for a practical example involving concurrency and ffi > in such a way as to expose some of the questions that need to be > answered. you're mentioning forkIO, so that's an example of such > questions: why shouldn't we be able to foreign export that? The (slightly glib) answer to this question is "because it doesn't have a legal FFI type". If you want to foreign export forkIO, you'll have to give me a version that I can foreign export. And that involves some important decisions: just where do you want to run the IO() action, on the server, or the client? If it's on the server, then how to I get the IO() in the first place? YOu must provide some more API functions to build a FunPtr(IO()), or something. (by server I mean the library proferring the forkIO API, by client I mean the client of this API). Cheers, Simon _______________________________________________ Haskell-prime mailing list [email protected] http://haskell.org/mailman/listinfo/haskell-prime
