[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Asynchronous I/O Egg Release

From: Kristian Lein-Mathisen
Subject: Re: [Chicken-users] Asynchronous I/O Egg Release
Date: Thu, 7 Jul 2016 14:04:07 +0200

I don't know how useful this is, but I though I'd throw in a test I use as we've encountered this a few times as well in the posix egg:

(use posix srfi-18)

(define mythread
   (lambda ()
     (let loop ()
       (define start (current-milliseconds))
       (thread-sleep! 0.1)
       (define elap (- (current-milliseconds) start))
       (if (> elap 500) ;; the 0.1 second sleep took > 0.5 seconds!
           (print "OBS! elap = " elap)

(print "cmd: sleep 1 ; echo hi" (with-input-from-pipe "sleep 1.5 ; echo hi" read-string))
(thread-join! mythread)

$ csi -version
Version (stability/4.9.0) (rev 8b3189b)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
bootstrapped 2014-06-07
$ csi -s blocking-io-test.scm 
cmd: sleep 1 ; echo hihi

OBS! elap = 1512.0

And this is a code-snippet we use to solve it.


On Fri, Jul 1, 2016 at 6:53 PM, Matt Welland <address@hidden> wrote:

On Fri, Jul 1, 2016 at 3:11 AM, Andy Bennett <address@hidden> wrote:

> And of course, reads of files on the file
> system never block at all

A read from a file can block when the operating system needs to go to
disk for the data. This happens when the buffer empties and it cannot be
refilled before the next read call.

I don't know if it applies to this discussion but read blocking can be quite a pain when a network fileserver such as NFS goes offline. It would be nice if other threads would continue so that the program could detect the issue and potentially take appropriate action such as let the user know *why* the program is hung.


0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF

Chicken-users mailing list

Chicken-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]