runtest :: Int -> Int -> IO ()
runtest n test = do
  c <- newc
  case test of
    0 -> do
      a <- async $ replicateM_ n $ writec c (1 :: Int)
      b <- async $ replicateM_ n $ readc c
      waitBoth a b
      return ()
    1 -> do
      replicateM_ n $ writec c (1 :: Int)
      replicateM_ n $ readc c
    2 -> do
      replicateM_ (n `quot` bufsiz) $ do
        replicateM_ bufsiz $ writec c (1 :: Int)
        replicateM_ bufsiz $ readc c
runtest :: Int -> Int -> IO ()
runtest n test = do
  c <- newc
  case test of
    0 -> do
      a <- async $ replicateM_ n $ writec c (1 :: Int)
      b <- async $ replicateM_ n $ readc c
      waitBoth a b
      return ()
    1 -> do
      replicateM_ n $ writec c (1 :: Int)
      replicateM_ n $ readc c
    2 -> do
      replicateM_ (n `quot` bufsiz) $ do
        replicateM_ bufsiz $ writec c (1 :: Int)
        replicateM_ bufsiz $ readc c
runtest n test = do
  c <- newc
  case test of
    0 -> do
      a <- async $ replicateM_ n $ writec c (1 :: Int)
      b <- async $ replicateM_ n $ readc c
      waitBoth a b
      return ()
    1 -> do
      replicateM_ n $ writec c (1 :: Int)
      replicateM_ n $ readc c
    2 -> do
      replicateM_ (n `quot` bufsiz) $ do
        replicateM_ bufsiz $ writec c (1 :: Int)
        replicateM_ bufsiz $ readc c