Re: [Haskell-cafe] Why does sleep not work?

2009-02-11 Thread George Pollard
On Wed, 2009-02-11 at 01:50 +0100, Manlio Perillo wrote: George Pollard ha scritto: [...] So, it seems nanosleep get interruped by a signal. This works: import System.Posix main = do putStrLn Waiting for 5 seconds. blockSignals $ addSignal sigVTALRM emptySignalSet

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread George Pollard
I can confirm this behaviour, on: Linux 2.6.27-11-generic #1 SMP i686 GNU/Linux Difference in the RTS between non-working and working: (RTS way, rts_thr) (RTS way, rts) - George signature.asc Description: This is a digitally signed message part

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread Corey O'Connor
The POSIX sleep function is defined as: sleep() makes the current process sleep until seconds seconds have elapsed or a signal arrives which is not ignored. Sounds like a signal is arriving that is interrupting the sleep. -Corey O'Connor 2009/2/9 John Ky newho...@gmail.com: Hi Peter,

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread Thomas DuBuisson
Not to say the issue shouldn't be tracked down, but shouldn't a more portable function be used anyway? untested example: maxBoundMicroSecInSec =(maxBound `div` 10^6) threadDelaySec :: Int - IO () threadDelaySec s | s maxBoundMicroSecInSec = threadDelay (maxBoundMicroSecInSec * 10^6)

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread Manlio Perillo
John Ky ha scritto: Hi Haskell Cafe, I wrote very short program to sleep for 5 seconds compiled with the -threaded option in ghc on the Mac OS X 1.5. I am finding that using the sleep function doesn't sleep at all, whereas using threadDelay does: [...] main = do putStrLn Waiting for

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread George Pollard
On Tue, 2009-02-10 at 09:57 -0800, Corey O'Connor wrote: The POSIX sleep function is defined as: sleep() makes the current process sleep until seconds seconds have elapsed or a signal arrives which is not ignored. Sounds like a signal is arriving that is interrupting the sleep. -Corey

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread George Pollard
On Wed, 2009-02-11 at 00:05 +0100, Manlio Perillo wrote: John Ky ha scritto: Hi Haskell Cafe, I wrote very short program to sleep for 5 seconds compiled with the -threaded option in ghc on the Mac OS X 1.5. I am finding that using the sleep function doesn't sleep at all, whereas

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread Corey O'Connor
2009/2/10 George Pollard por...@porg.es: import System.Posix main = do putStrLn Waiting for 5 seconds. blockSignals $ addSignal sigVTALRM emptySignalSet sleep 5 putStrLn Done. Huh! Does the GHC runtime uses this signal? Perhaps for scheduling? Cheers, -Corey

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread George Pollard
Also attached is a diff for strace between non-threaded and threaded. execve(./sleep, [./sleep], [/* 38 vars */]) = 0 execve(./sleep, [./sleep], [/* 38 vars */]) = 0 brk(0) = 0x83c2000 | brk(0) = 0x8ff

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread Manlio Perillo
Corey O'Connor ha scritto: 2009/2/10 George Pollard por...@porg.es: import System.Posix main = do putStrLn Waiting for 5 seconds. blockSignals $ addSignal sigVTALRM emptySignalSet sleep 5 putStrLn Done. Huh! Does the GHC runtime uses this signal? Perhaps for

Re: [Haskell-cafe] Why does sleep not work?

2009-02-10 Thread Manlio Perillo
George Pollard ha scritto: [...] So, it seems nanosleep get interruped by a signal. This works: import System.Posix main = do putStrLn Waiting for 5 seconds. blockSignals $ addSignal sigVTALRM emptySignalSet sleep 5 putStrLn Done. So (see my earlier

[Haskell-cafe] Why does sleep not work?

2009-02-09 Thread John Ky
Hi Haskell Cafe, I wrote very short program to sleep for 5 seconds compiled with the -threaded option in ghc on the Mac OS X 1.5. I am finding that using the sleep function doesn't sleep at all, whereas using threadDelay does: main = do putStrLn Waiting for 5 seconds. threadDelay

Re: [Haskell-cafe] Why does sleep not work?

2009-02-09 Thread Bulat Ziganshin
Hello John, Tuesday, February 10, 2009, 12:35:25 AM, you wrote: I am finding that using the sleep function doesn't sleep at all, whereas using threadDelay does: Anybody know what's happening? 1) this depends on your sleep definition 2) read threadDelay docs -- Best regards, Bulat

Re: [Haskell-cafe] Why does sleep not work?

2009-02-09 Thread Peter Verswyvelen
Hi John, Which sleep are you using? From which module? Can you show the full source with import statements? Cheers, Peter 2009/2/9 John Ky newho...@gmail.com Hi Haskell Cafe, I wrote very short program to sleep for 5 seconds compiled with the -threaded option in ghc on the Mac OS X 1.5. I

Re: [Haskell-cafe] Why does sleep not work?

2009-02-09 Thread John Ky
Hi Peter, Source code: import System.IO import System.Posix main = do putStrLn Waiting for 5 seconds. sleep 5 -- doesn't sleep at all putStrLn Done. OS: Mac OS X 10.5 Compile command: ghc --threaded testsleep.hs If I remove --threaded, then it does sleep. Thanks, -John On