I can't figure out why this deadlocks on me (I'm using beta 14):
(let ((x (open-vector))) (thread-start! (make-thread (lambda () (write 1 x)))) (thread-start! (make-thread (lambda () (write 2 x)))) (read x) (read x)) *** ERROR IN ##thread-deadlock-action! -- Deadlock detected
Shouldn't this run to completion (possibly blocking at times to wait for the writes), and return either 2 or 1?
- Matt
Afficher les réponses par date
On 9-Aug-05, at 2:55 PM, Matthew Morgan wrote:
I can't figure out why this deadlocks on me (I'm using beta 14):
(let ((x (open-vector))) (thread-start! (make-thread (lambda () (write 1 x)))) (thread-start! (make-thread (lambda () (write 2 x)))) (read x) (read x)) *** ERROR IN ##thread-deadlock-action! -- Deadlock detected
Shouldn't this run to completion (possibly blocking at times to wait for the writes), and return either 2 or 1?
I/O is buffered, so you need to force the output to be sent to the vector-port (and available to be read). This is what you should do:
(let ((x (open-vector))) (thread-start! (make-thread (lambda () (write 1 x) (force-output x)))) (thread-start! (make-thread (lambda () (write 2 x) (force-output x)))) (read x) (read x))
Marc
On 8/10/05, Marc Feeley wrote:
I/O is buffered, so you need to force the output to be sent to the vector-port (and available to be read).
Ah, I see. So I could either call force-output for every write or create an unbuffered vector port with (open-vector (list output-buffering: #f)).
Thanks! - Matt