[Haskell-cafe] Re: Export Haskell Libraries
mattcbro at earthlink.net
Fri Apr 13 15:33:14 EDT 2007
Dan Weston wrote:
> In the GHC docs:
> "There can be multiple calls to hs_init(), but each one should be
> matched by one (and only one) call to hs_exit()."
> What exactly happens with nested calls? Is there only one runtime
> created, with a simple counter to know which hs_exit should shut it
> down? If so, is there a way of having multiple interpreters open safely
> at the same time?
> Or does each hs_init() create a new separate concurrent runtime (the
> preferable alternative)?
> And what is the cost of creating and destructing the GHC runtime anyway?
> Can the Haskell interpreter be in a Linux shared-object library, so long
> as I make sure to call hs_init() after loading and hs_exit() before
> unloading it? My experiments so far show this working flawlessly, but I
> vaguely remember an e-mail thread saying GHC couldn't be linked in
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Thats a good question. I know that on windows multiple calls to loadLibrary
end up returning memory to the same shared area, although different
processes have their own data block (but still share the code block).
Unfortunately the same process with different threads share the same data
block, potentially causing issues if static memory gets altered. Thus it's
up to the programmer to create and initialize any static memory that should
be unique to a thread. Perhaps hs_init() does this, I do not know.
View this message in context: http://www.nabble.com/Export-Haskell-Libraries-tf3569747.html#a9985245
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe