lua-users home
lua-l archive

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


On Fri, Sep 01, 2006 at 06:35:23PM -0700, Mark Hamburg wrote:
> On OS's with decent disk caches, writes are generally effectively
> non-blocking unless you get ahead of what memory can hold and then you are
> stuck no matter what.

You're not stuck; as you said, scheduling.  A multi-task, single-thread
FTP client could run other transfers while waiting for writes to a slow
USB drive to catch up.

> Reads are effectively non-blocking if the data is in the disk cache.
> 
> So, that leaves the problem of reading when the data isn't in the disk
> cache. The only way that can be "non-blocking" is if you can go and do
> something else while waiting for the data. To do that, one needs a scheduler
> and a task system. It isn't that hard to write such a thing in Lua, but
> there isn't one that comes for free out of the box as it were.

But there's no (portable) way of knowing whether a given read will be
satisfied out of cache.

A related problem is directory access and related operations: if you
want nonblocking file I/O, you may also want nonblocking directory
scanning, and nonblocking file opening.  The single-thread FTP client 
sending a file on a DVD drive that has to spin up would want to continue
other tasks while waiting.

-- 
Glenn Maynard