home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.wizards
- Path: sparky!uunet!utcsri!newsflash.concordia.ca!sifon!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Subject: Re: system call write
- Message-ID: <1992Nov15.203922.21164@thunder.mcrcim.mcgill.edu>
- Organization: McGill Research Centre for Intelligent Machines
- References: <1992Nov13.164855.14013@tamsun.tamu.edu>
- Date: Sun, 15 Nov 92 20:39:22 GMT
- Lines: 34
-
- In article <1992Nov13.164855.14013@tamsun.tamu.edu>, pnarayan@cs.tamu.edu (P S Narayan) writes:
-
- > When I do a write (fd, buf, bytes), assuming that the file descriptor
- > refers to an open block device say disk, is the kernel going to copy
- > buf from user space to system buffer or is it going to flush it
- > immediately onto disk ?
-
- This is of course system-dependent. Every system I know of (which for
- knowledge at this level is restricted to BSD derivatives) will have
- copied the data out of your buffer by the time write() returns. The
- relevant buffers in the buffer cache will be marked dirty and will be
- flushed to disk at the next sync() or when buffers are needed for some
- other use.
-
- > In that case how can the user process without closing the files,
- > ensure that his write system call flushes info onto disk ? Is there a
- > way to do it ?
-
- > My question is how can I get synchronous write ?
-
- If you're accessing a file, I know of no way; at best you can make it
- push the dirty pages immediately, but I don't know of any way to wait
- until the I/O actually completes. If you're using a special device, it
- is of course up to the driver; all block special devices I know of
- behave like files in this respect. Character special devices are,
- usually, better: they tend to wait until the I/O completes.
-
- Of course, given things like caching disk controllers, it may not be
- possible to tell whether the bits have actually reached the medium.
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-