|
RE: stdin set to nonblocking mode: msg#00080lang.haskell.glasgow.bugs
On 11 August 2005 14:59, Sigbjorn Finne wrote: > "Simon Marlow" <simonmar@xxxxxxxxxxxxx> writes: >> On 11 August 2005 01:18, John Meacham wrote: >> >>> Why do we set file descriptors to nonblocking mode anyway if they >>> are waited on by a select. there shouldn't be a need to use both >> >> It avoids an extra system call per read(), i.e. a single read() >> instead of select() + read(). And there's a slight chance of a race >> between the select() and read() calls, if some other thread or >> process is reading from the same descriptor. With non-blocking >> read(), this isn't an issue. >> >> The overhead of the extra syscall is probably a non-issue, but the >> race is mildly worrying. >> > > The main reason for using non-blocking descriptors is that select() > only tells you that I/O is possible over a descriptor, not the > amount. Hence block read()s and writes() run the real risk of > blocking the whole system. Insisting on single byte read()/write()s > is not an option ;-) No - read() can always return less than the requested amount of data, even when not in O_NONBLOCK mode. Cheers, Simon
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [ ghc-Bugs-1206426 ] SHGetFolderPath link error, SourceForge.net |
|---|---|
| Next by Date: | Re: stdin set to nonblocking mode, Sigbjorn Finne |
| Previous by Thread: | Re: stdin set to nonblocking mode, Sigbjorn Finne |
| Next by Thread: | Re: stdin set to nonblocking mode, Sigbjorn Finne |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |