[Haskell-cafe] Unbound threads and FFI

Simon Peyton-Jones simonpj at microsoft.com
Fri Dec 16 04:23:13 EST 2005


I've added a FAQ.

Simon

| -----Original Message-----
| From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of
| Simon Marlow
| Sent: 15 December 2005 09:26
| To: Bulat Ziganshin
| Cc: Haskell-Cafe Cafe
| Subject: RE: Re[2]: [Haskell-cafe] Unbound threads and FFI
| 
| On 14 December 2005 18:04, Bulat Ziganshin wrote:
| 
| > Hello Simon,
| >
| > Wednesday, December 14, 2005, 7:39:43 PM, you wrote:
| >
| >> Do other Haskell threads get blocked during an FFI call?
| >
| >>               | safe    unsafe
| >> --------------+----------------
| >>  -threaded    | NO      YES
| >>  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.
| 
| threadsafe is deprecated; it is currently exactly the same as safe.
We
| thought at one time that it would be useful to have the distinction,
but
| it turned out to be impractical to implement safe that wasn't also
| threadsafe.
| 
| Cheers,
| 	Simon
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe at haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list