Hi Raymond,
I'm doing log analysis stuff, so I need to be able to watch both regular files and fifos (probably more :). I also need to be able to monitor multiple files. So, in short, blocking in any way is bad news for me as I don't want to get into threads, etc. :) In my code, I have an inner loop that tries to read a line from each file in sequence. By adding a very small sleep (I request .03 seconds) after trying every file and having nothing to read, I reduce the CPU usage from near 100% to near 0% when there is nothing to do! Quite frankly, I was *floored* by the difference the miniscule (for my application) sleep made. I thought I'd share :) Thanks all, Jim James E. Prewett Systems Team Leader 505.277.8210 Designated Security Officer [EMAIL PROTECTED] [EMAIL PROTECTED] HPC Systems Engineer III @ [EMAIL PROTECTED] OpenPGP key: pub 1024D/31816D93 On Thu, 13 Jan 2005, Raymond Toy wrote: >>>>>> "Harald" == Harald Hanche-Olsen <[EMAIL PROTECTED]> writes: > > Harald> Nah. You can open it nonblocking. Works fine on freebsd, which > you > Harald> say you are using: > > CL-USER> (defparameter *fifofd* (unix:unix-open > Harald> "/tmp/fifo" > Harald> (logior unix:o_rdonly unix:o_nonblock) > Harald> #o444)) > Harald> *fifofd* > CL-USER> *fifofd* > Harald> 8 > CL-USER> (defparameter *fifo* (system:make-fd-stream *fifofd* :input t)) > Harald> *fifo* > > Harald> Now *fifo* is an ordinary Lisp stream which you can read to your > Harald> heart's content. > > By doing this, does it mean that now all reads from that fifo need to > be checked to see if anything was actually read? Or, perhaps, than we > have Lisp read the stream, 100% CPU will be spent constantly reading > the fifo until something is available? > > Just curious, > > Ray >
