home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / wizards / 4700 < prev    next >
Encoding:
Text File  |  1992-11-15  |  1.9 KB  |  44 lines

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