Re: Programming Question: non-blocking I/O
From: Robert Heller (heller_at_deepsoft.com)
Date: 04/06/04
- Next message: mjt: "Re: Kernel Oops, then processes cannot be killed"
- Previous message: Feed_me_spam: "Re: accessing a ZIP drive"
- In reply to: Don M: "Programming Question: non-blocking I/O"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 06 Apr 2004 01:50:56 +0200
donm@calculex.com (Don M),
In a message on 5 Apr 2004 09:21:15 -0700, wrote :
DM> I'm porting an app from Windows to Linux and have not yet found how to
DM> do non-blocking I/O on a file (aka asynchronous or "overlapped" I/O).
DM>
DM> Under Windows, you call WriteFile() and pass it an Event which you
DM> later pass to a wait function when you run out of other things to do.
DM> How is this done under Linux?
DM>
DM> I've found reference to two flags O_ASYNC and O_NONBLOCK on the man
DM> page for open(), but these don't appear to be applicable to regular
DM> files.
They are not.
The thing is this: *Originally* (eg Win 3.11) Windows was a cooperative
'multi-'tasking operating system. There was not either a 'real' kernel
now any sort of background processing for disk I/O. Early versions of
Windows 'faked' this.
Under UNIX (and Linux), *actual* disk I/O (low-level I/O) is handled via
various background tasks in the kernel. From a user-level process, disk
I/O is always synchronous and effectively instantaneous -- user process
don't every actually wait for the bits to fully land on the disk
platters. The bits end up in a disk cache buffer and are flushed to the
disk platters sometime later (usually in a few seconds or the next time
there are no jobs in the run queue or some process invokes the sync
command).
The only time you use O_ASYNC or O_NONBLOCK is for slow I/O devices
(serial ports, parallel ports, keyboards, etc.) and for things like
pipes and sockets (network).
DM>
DM> Thanks,
DM> Don
DM>
\/
Robert Heller ||InterNet: heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller || heller@deepsoft.com
http://www.deepsoft.com /\FidoNet: 1:321/153
- Next message: mjt: "Re: Kernel Oops, then processes cannot be killed"
- Previous message: Feed_me_spam: "Re: accessing a ZIP drive"
- In reply to: Don M: "Programming Question: non-blocking I/O"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|