Re: Re[2]: FFI: number of worker threads?

2006-06-21 Thread Li, Peng
On 6/21/06, Simon Peyton-Jones [EMAIL PROTECTED] wrote: New worker threads are spawned on as needed. You'll need as many of them as you have simultaneously-blocked foreign calls. If you have 2000 simultaneously-blocked foreign calls, you'll need 2000 OS threads to support them, which probably

Re: Re[2]: FFI: number of worker threads?

2006-06-21 Thread Li, Peng
On 6/21/06, Duncan Coutts [EMAIL PROTECTED] wrote: On linux, epoll scales very well with minimal overhead. Using multiple OS threads to do blocking IO would not scale in the case of lots of idle socket connections, you'd need one OS thread per socket. On Linux, OS threads can also scale very

FFI: number of worker threads?

2006-06-20 Thread Li, Peng
Hello, The paper Extending the Haskell FFI with Concurrency mentioned the following in Section 6.3: GHC's run-time system employs one OS thread for every bound thread; additionally, there is a variable number of so-called worker OS threads that are used to execute the unbounded (lightweight)

readChan and unGetChan?

2006-04-03 Thread Li, Peng
Suppose the following happens: (1) Thread A calls readChan on an empty channel and waits (2) Thread B puts something to the read-end of the channel using unGetChan When a GHC program does this, both threads are blocked! Is it the behaviour we really want for unGetChan, or should we fix the

Allocating aligned memory?

2006-03-03 Thread Li, Peng
In GHC, how can I allocate a chunk of memory aligned to some block size (say, 512 or 1024 bytes)? I tried to specify it in the alignment method in the Storable typeclass, but that does not seem to work. Is Storable.alignment really used in GHC? If so, is there a code example that allocates aligned

Using GHC with SMP and FFI?

2006-03-03 Thread Li, Peng
[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

Read integer from prompt

1999-09-23 Thread Li Peng
hi In the older hugs, i do this to read in integer from standard input: readNum :: IO Integer readNum = do { line - getLine ; readIO line } However, in hugs98, it failed and the error message is: