[Haskell-cafe] Unbound threads and FFI

Bulat Ziganshin bulatz at HotPOP.com
Wed Dec 14 13:03:51 EST 2005


Hello Simon,

Wednesday, December 14, 2005, 7:39:43 PM, you wrote:

SM> Do other Haskell threads get blocked during an FFI call?

SM>               | safe    unsafe
SM> --------------+----------------
SM>  -threaded    | NO      YES
SM>  no -threaded | YES     YES

there is also `threadsafe` specifier. i don't understand from the docs
what it exactly means?

ghc commentary says:

To signal that you want an external call to be serviced by a separate
OS thread, you have to add the attribute threadsafe to a foreign
import declaration, i.e.,

foreign import "bigComp" threadsafe largeComputation :: Int -> IO ()

The distinction between 'safe' and thread-safe C calls is made so that
we may call external functions that aren't re-entrant but may cause a
GC to occur.  

The threadsafe attribute subsumes safe. 


-- 
Best regards,
 Bulat                            mailto:bulatz at HotPOP.com





More information about the Haskell-Cafe mailing list