Date: Fri, 7 Jan 2000 12:33:59 -0500 (EST) From: Zhihui Zhang <zzhang@cs.binghamton.edu> To: Scott Hess <scott@avantgo.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Questions about select() and O_NONBLOCK Message-ID: <Pine.GSO.3.96.1000107122752.720B-100000@sol.cs.binghamton.edu> In-Reply-To: <04a501bf593c$72930210$1e80000a@avantgo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 7 Jan 2000, Scott Hess wrote: > Zhihui Zhang <zzhang@cs.binghamton.edu> wrote: > > I hope that someone will clarify the following questions for me: > > > > (1) Can select() be used with regular files, like myfile.txt? > > > > (2) Does O_NONBLOCK or O_NDELAY work on regular files? > > > > Any help is appreciated. > > At this time, regular files are _always_ ready for I/O, and _always_ > fulfill your complete request (barring other problems, such as end-of-file > our out-of-space conditions). This is actually the case for all Unix > implementations I'm aware of, though there are sometimes ways to work > around the problem (async I/O, for instance). > > [I've been spending the past week working around this problem in the > pthreads library - since file I/O blocks below the pthreads library, disk > I/O is effectively serialized when using pthreads. I'm working on > integrating rfork() threads to handle disk I/O instead, so that multiple > requests can be pending at a given time.] Thanks a lot for your clarification. This saves me a lot of time reading the kernel source. As for the pthreads you mentioned, it sounds like a user level implementation of KAIO (see vfs_aio.c). If I understand it correctly, the kernel already maintains a queue for asynchronous I/O jobs, though there is a limit of the length of that queue. -Zhihui To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.3.96.1000107122752.720B-100000>