Re: How do disk writes work these days?
Re: How do disk writes work these days?
- Subject: Re: How do disk writes work these days?
- From: Pelle Johansson <email@hidden>
- Date: Tue, 30 Jul 2002 16:38:42 +0200
torsdagen den 25 juli 2002 kl 11.04 skrev Timothy A. Seufert:
Wade Tregaskis <email@hidden> wrote:
Wade -- one thing you might want to look in to is that some operating
systems implement an asynchronous I/O API in addition to traditional
blocking synchronous I/O. For asynch, the difference in the
sequence of
events (from userland POV) is that the initial I/O call doesn't
block,
and there is always some mechanism to notify the process of I/O
completion. In "classic" MacOS, ISTR this was done by giving the
OS a
pointer to a callback function, which would be called on error or
completion. I think it also set a flag in the descriptor structure
used
to request the I/O, so you could also determine completion by polling
that flag.
Is this still an efficient way of operating, in an increasingly linear
[e.
g. single-user] OS? I'm just thinking, if you could return from writes
faster, the calling process can keep doing other things.
The classic way of doing this in UNIX systems is to make the
application multithreaded. By splitting things into an I/O thread and
a (other stuff) thread, you can avoid making the whole program stop
every time it needs to do I/O.
IMO, a much better way, in programs where it is possible, is to use
O_NONBLOCK (in either open() or fcntl()) and select() to check for
writable file descriptors. Most programs should in fact be centered
around a select() call. If you wish, you can check for SIGIO as well,
but it is usually not necessary.
--
Pelle Johansson
<email@hidden>
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.