Hi Zhen,

Although you might be resolved, there are some information.

In your example code, threads are waiting a MVar for each IO(print). 
(thread switch by self yield rather than timer-based(preemptive) scheduling) 

Maybe, these information would be helpful.

    Parallel and Concurrent Programming in Haskell
    Chapter 7. Basic Concurrency: Threads and MVars
    http://chimera.labs.oreilly.com/books/1230000000929/ch07.html

    The GHC scheduler
    http://blog.ezyang.com/2013/01/the-ghc-scheduler/

    Runtime Support for Multicore Haskell
    http://research.microsoft.com/en-us/um/people/simonpj/papers/parallel/multicore-ghc.pdf

    Extending the Haskell Foreign Function Interface with Concurrency
    http://community.haskell.org/~simonmar/papers/conc-ffi.pdf

And, ThreadScope and eventlog are here.

    Parallel and Concurrent Programming in Haskell
    15. Debugging, Tuning, and Interfacing with Foreign Code
    Event Logging and ThreadScope
    http://chimera.labs.oreilly.com/books/1230000000929/ch15.html#sec_conc_eventlogging

    ThreadScope
    https://wiki.haskell.org/ThreadScope


So, few image.
    http://takenobu-hs.github.io/downloads/haskell_ghc_illustrated.pdf#page=82
    http://takenobu-hs.github.io/downloads/haskell_ghc_illustrated.pdf#page=47


Cheers,
Takenobu


2015-07-05 14:10 GMT+09:00 Zhen Zhang <izgzhen@gmail.com>:
Hi Ryan,

Thank for your help. But it turned out to be not working for me. I even commented out the `startTimer` and `stopTimer` in `rts/Timer.c`, but it seems not working as well.

For example. this program:

main = do
forkIO $ forever $ print “a”
forkIO $ forever $ print “b”
threadDelay 100000

When I added the `-threaded`, it will schedule normally, despite whether I commented out some code or add `-V0`. When I dropped  `-threaded`, the `timerManager` stopped working as well, so it doesn’t make sense to me. Bad luck, but thank you all the way.

Zhen

-- 
Zhen Zhang
USTC, China

On July 4, 2015 at 10:08:44 PM, Ryan Yates (fryguybob@gmail.com) wrote:

Hi Zhen,

The RTS flag -V sets the tick interval (setting to 0 disables).  If you grep for `RtsFlags.MiscFlags.tickInterval` you can find where it gets used.  Hope this helps.

Ryan

On Sat, Jul 4, 2015 at 6:25 AM, Zhen Zhang <izgzhen@gmail.com> wrote:
Hi,

I am trying to stop the GHC thread scheduler from atomically do round-robin scheduling. It might be strange that I am asking for that, in fact, my intention is to implement the “Lightweight Concurrency” on top of current RTS system. I am trying to use `GHC.Event`’s timeout mechanism to interfere with the scheduling behavior and it seems working a bit. But the automatic scheduling at the same time by RTS renders this effort invalid.

For this part, I have tried to modify `rts/Scheduler.c`, masked some `startTimer` in `schedule()`, change the `appendToQueue` to `pushOnQueue` in `scheduleHandleYield` but nothing really works. (The GHC is still doing RR scheduling, even I changed some key code I thought)

So I am curious if anyone familiar with the RTS could give me some suggestions on this problem.

Thanks a lot!

Zhen



_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs



_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs