Profiling and Threading: never the twain shall meet

Hi Haskellers, It seems that profiling and threading are not supported at the same time in GHC6.6. At least, it objects to using both the flags at the same time, and there's a Trac entry for that issue. So I just wanted to be sure that I really need threading. I'm passing text through some filters written in perl, just ordinary command line programs. I do it like this:
do (hin, hout, herr, ph) <- runInteractiveProcess cmd args Nothing Nothing forkIO $ hPutStr hin content >> hClose hin out <- hGetContents hout return (ph, out)
which seems to require threading. If I compile without, it will hang indefinitely, I presume deadlocked. Is there a way this can be done without threading? But it's not a great issue for me if I can't do profiling in this case. I just wanted to try out the feature, and it seemed worthwhile checking I was doing this right. Cheers, Dougal.

Dougal Stanton wrote:
do (hin, hout, herr, ph) <- runInteractiveProcess cmd args Nothing Nothing forkIO $ hPutStr hin content >> hClose hin out <- hGetContents hout return (ph, out)
which seems to require threading. If I compile without, it will hang indefinitely, I presume deadlocked. Is there a way this can be done without threading?
With much sweat, you could write your own timed polling loop and avoid threads, using hPutBufNonBlocking and hGetBufNonBlocking. I don't recommend it, except for fun or self-torture.

Dougal Stanton wrote:
It seems that profiling and threading are not supported at the same time in GHC6.6. At least, it objects to using both the flags at the same time, and there's a Trac entry for that issue.
So I just wanted to be sure that I really need threading. I'm passing text through some filters written in perl, just ordinary command line programs. I do it like this:
do (hin, hout, herr, ph) <- runInteractiveProcess cmd args Nothing Nothing forkIO $ hPutStr hin content >> hClose hin out <- hGetContents hout return (ph, out)
which seems to require threading. If I compile without, it will hang indefinitely, I presume deadlocked. Is there a way this can be done without threading?
You certainly can use threading with profiling, just not the "threaded RTS" that you get with the -threaded option. There are certain restrictions that apply when you don't use -threaded, but ordinary forkIO works fine. http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#... Cheers, Simon
participants (3)
-
Albert Y. C. Lai
-
Dougal Stanton
-
Simon Marlow