[plt-scheme] mzscheme, open-input-file and threads

From: Tom Wooldridge (twooldri at cs.brown.edu)
Date: Tue Aug 13 09:31:21 EDT 2002

Hi.

I've encountered some seemingly strange behavior in both MzScheme v200
and v201. 

It seems that when `open-input-file' blocks, the other running threads
starve.  In particular, `open-input-file' will block when the file it's
trying to open is a pipe. 

Here's a recreation of the behavior:

First, run `mkfifo /tmp/a-test-pipe'.  Then, run the following code:

(define (evil-block)
  (open-input-file "/tmp/a-test-pipe"))

(define (print-foo)
  (display "foo\n")
  (sleep 2)
  (print-foo))

(thread (lambda () (evil-block)))
(thread (lambda () (print-foo)))

When the code is first run, `foo' won't get displayed more than once or
twice.  After that, nothing happens until a process tries to write to
the pipe (ie: `cat > /tmp/a-test-pipe' will get `print-foo' going
again).

Might this be a bug? :-)

Thanks.
-Tom




Posted on the users mailing list.