Commit 2eaf89de authored by simonmar's avatar simonmar
Browse files

[project @ 2005-05-23 13:45:51 by simonmar]

conc051 tests MVar throughput between the main thread and a child
thread.  In the threaded/SMP runtimes, this kind of communication has
a high overhead because real OS threaded switches are required (the
main thread is bound, the child thread is unbound).  It's a good
stress test, anyhow.
parent fadfd2cc
......@@ -60,20 +60,20 @@ test('conc032', only_compiler_types(['ghc']), compile_and_run, [''])
# Omit for GHCi, because it just sits there waiting for you to press ^C
# Also hangs with the threaded RTS
test('conc033', omit_ways(['ghci','threaded']), compile_and_run, [''])
test('conc033', omit_ways(['ghci']), compile_and_run, [''])
# Omit for GHCi, because it just sits there waiting for you to press ^C
# Also hangs with the threaded RTS
test('conc034', compose(only_compiler_types(['ghc']),
compose(omit_ways(['ghci','threaded']),
compose(omit_ways(['ghci','threaded', 'smp']),
extra_run_opts('+RTS -C0 -RTS'))),
compile_and_run, [''])
test('conc035', only_compiler_types(['ghc']), compile_and_run, [''])
test('conc036', only_compiler_types(['ghc']), compile_and_run, [''])
test('conc037', only_ways(['threaded']), compile_and_run, [''])
test('conc038', only_ways(['threaded']), compile_and_run, [''])
test('conc037', only_ways(['threaded','smp']), compile_and_run, [''])
test('conc038', only_ways(['threaded','smp']), compile_and_run, [''])
# Omit for GHCi, uses foreign export
test('conc039', omit_ways(['ghci']), compile_and_run, [''])
......@@ -82,7 +82,7 @@ test('conc039', omit_ways(['ghci']), compile_and_run, [''])
# Omit threaded RTS: Hangs forever
test('conc040', compose(only_compiler_types(['ghc']),
compose(exit_code(1),
omit_ways(['ghci','threaded']))),
omit_ways(['ghci','threaded', 'smp']))),
compile_and_run, [''])
# STM-related tests. As with conc033, omit threaded in 047 and 048 because
......@@ -106,3 +106,5 @@ test('conc049', only_compiler_types(['ghc']), compile_and_run, ['-package stm'])
# 'opt' ways. (ToDo)
# test('conc050', compose(only_compiler_types(['ghc']), extra_run_opts('10000')), compile_and_run, ['-package stm'])
test('conc050', skip, compile_and_run, ['-package stm'])
test('conc051', normal, compile_and_run, [''])
module Main (main) where
import System.Environment
import Control.Concurrent
import Control.Monad
-----------------------------------------------------------------------------
-- test MVar throughput between the main thread and a child thread
-- This test runs quite slowly on the threaded/SMP RTS vs. the normal RTS,
-- because the main thread and child thread are run by different OS threads,
-- so each MVar communication requires real OS thread switching.
--
-- Figures I get are about a factor of 10 difference in speed, at GHC 6.5.
main = chanTest 300000
chanTest :: Int -> IO ()
chanTest n = do
chan <- newEmptyMVar
forkIO (writer chan n)
reader chan n
reader chan 0 = return ()
reader chan n = do
takeMVar chan
reader chan (n-1)
writer chan 0 = return ()
writer chan n = do
putMVar chan ()
writer chan (n-1)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment