IO concurrency

Max Kirillov max630@mail.ru
Tue, 16 Oct 2001 02:34:28 +0700


On Mon, Oct 15, 2001 at 04:47:25PM +0100, Simon Marlow wrote:
> I tried this here on Linux/x86 with 5.02 and it seems to work fine.
> Instead of the tcl/tk script you mentioned I used a FIFO in /tmp/fifo
> and made the runProcess just call "cat /tmp/fifo".

> Which GHC version and platform is this on?

I test your example. It doesn't work for me. Both for 5.00.1
and 5.00.2. That's glibc-2.0.7/linux-2.2.19/x86 (does it
matter?). Tried both with '-O -fglasgow-exts' and no
options. I't quite stable behavior.

that's what strace told me:

succeeded case:

------------ cut begin
> gettimeofday({1002682961, 979251}, NULL) = 0
> select(1, [0], [], NULL, {0, 0})        = 0 (Timeout)
> gettimeofday({1002682961, 980192}, NULL) = 0
> write(1, "tick\n", 5)                   = 5
> gettimeofday({1002682961, 981179}, NULL) = 0
> gettimeofday({1002682961, 981525}, NULL) = 0
> select(1, [0], [], NULL, {1, 0})        = 0 (Timeout)
> gettimeofday({1002682962, 980292}, NULL) = 0
[skipped]
> select(1, [0], [], NULL, {0, 0})        = 0 (Timeout)
> gettimeofday({1002682963, 162}, NULL)   = 0
> write(1, "tick\n", 5)                   = 5
> gettimeofday({1002682963, 1134}, NULL)  = 0
> gettimeofday({1002682963, 1497}, NULL)  = 0
> select(1, [0], [], NULL, {1, 0})        = 0 (Timeout)
> gettimeofday({1002682964, 433}, NULL)   = 0
[skipped..repeated several times]
> select(1, [0], [], NULL, {0, 0})        = 0 (Timeout)
> gettimeofday({1002682964, 20740}, NULL) = 0
> write(1, "tick\n", 5)                   = 5
> gettimeofday({1002682964, 21560}, NULL) = 0
> gettimeofday({1002682964, 21876}, NULL) = 0
> select(1, [0], [], NULL, {1, 0})        = 1 (in [0], left {0, 250000})
> read(0, "qwertrt\n", 8192)              = 8
> write(1, "qwertrt\n", 8)                = 8
> read(0, 0x8079f80, 8192)                = -1 EAGAIN (Resource temporarily unavailable)
> gettimeofday({1002682964, 772256}, NULL) = 0
> select(1, [0], [], NULL, {0, 260000})   = 0 (Timeout)
> gettimeofday({1002682965, 30227}, NULL) = 0
> select(1, [0], [], NULL, {0, 0})        = 0 (Timeout)
------------ cut end

failed case:

------------ cut begin
> brk(0x8085000)                          = 0x8085000
> write(1, "tick\n", 5)                   = 5
> gettimeofday({1002682710, 783155}, NULL) = 0
> gettimeofday({1002682710, 783502}, NULL) = 0
> select(0, [], [], NULL, {0, 0})         = 0 (Timeout)
> read(4, "click\n", 8192)                = 6
> write(1, "click\n", 6)                  = 6
> read(4, "click\n", 8192)                = 6
> write(1, "click\n", 6)                  = 6
------------ cut end


I didn't try ghc-5.02 since I haven't installed it yet.

Max.