home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / vms / 19976 < prev    next >
Encoding:
Text File  |  1992-12-29  |  3.7 KB  |  82 lines

  1. Newsgroups: comp.os.vms
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!decwrl!deccrl!news.crl.dec.com!dbased.nuo.dec.com!nntpd.lkg.dec.com!nntpd2.cxo.dec.com!adserv.enet.dec.com!winalski
  3. From: winalski@adserv.enet.dec.com (Paul S. Winalski)
  4. Subject: Re: flushing in VAXC and DECC
  5. Message-ID: <1992Dec28.232610.13589@nntpd2.cxo.dec.com>
  6. Lines: 69
  7. Sender: usenet@nntpd2.cxo.dec.com (USENET News System)
  8. Reply-To: winalski@adserv.enet.dec.com (Paul S. Winalski)
  9. Organization: Digital Equipment Corporation, Nashua NH
  10. References: <1992Dec26.211521.4768@spcvxb.spc.edu> <6813@npri6.npri.com>,<1992Dec27.055031.24162@eco.twg.com> <1hjtr9INN34t@gap.caltech.edu>,<1992Dec27.200611.24473@nntpd2.cxo.dec.com> <1hn91uINNnna@gap.caltech.edu>
  11. Date: Mon, 28 Dec 1992 23:26:10 GMT
  12.  
  13.  
  14. In article <1hn91uINNnna@gap.caltech.edu>,
  15. carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick) writes:
  16. |>
  17. |>In article <1992Dec27.200611.24473@nntpd2.cxo.dec.com>,
  18. |>winalski@adserv.enet.dec.com (Paul S. Winalski) writes:
  19. |>>The function behaves as documented.  It flushes all of the C RTL's internal
  20. |>>buffers and it also does an RMS SYS$FLUSH to force the data to be written to
  21. |>>disk.
  22. |>>
  23. |>>You're being caught by the special RMS processing for process-permanent files.
  24. |>
  25. |>Afraid not.  The same thing happens with the program:
  26. |>    #include stdio
  27. |>    main()
  28. |>    {    FILE *fp;
  29. |>        fp = fopen("TEST.DAT", "w");
  30. |>        fprintf(fp, "This is a test.\n");
  31. |>        fsync(fileno(fp));
  32. |>        sleep(30);
  33. |>    }
  34. |>
  35. |>fsync() *MUST* be preceded by an fflush() if you want to be sure that all stuff
  36. |>that's already been written using standard I/O calls is flushed to disk.  And,
  37. |>byt the way, despite the claim by another person, the program:
  38. |>
  39. |>#include stdio
  40. |>main()
  41. |>{    int fd;
  42. |>    fd = creat("TEST.DAT");
  43. |>    write(fd, "This is a test.\n", 16);
  44. |>    fsync(fd);
  45. |>    sleep(30);
  46. |>}
  47. |>
  48. |>Also exhibits exactly the same behavior.  Unfortunately, there doesn't appear
  49. |>to be any documented way to flush the C I/O buffers if you've been using
  50. |>write() instead of standard I/O.
  51. |>
  52. |>>When you do a SPAWN/NOWAIT/OUT=filespec, SYS$OUTPUT (aka stdout) is opened in
  53. |>>supervisor mode by DCL as a process-permanent file.  This is done so that each
  54. |>>program run in the subprocess doesn't create its own version of the output file.
  55. |>>Many user-mode RMS operations on a process-permanent file end up being no-ops.
  56. |>>Among these are SYS$OPEN, SYS$CLOSE, and SYS$FLUSH.  So what happens here is
  57. |>>that the DECC RTL does write its buffers and do a SYS$FLUSH, but RMS ignores
  58. |>>the SYS$FLUSH because stdout is a process-permanent file.
  59. |>
  60. |>>Note that your second program above (the one with the fflush()) behaves
  61. |>>identically to the first one--you still don't see "This is a test." until the
  62. |>>subprocess terminates.  This is because the fsync()'s SYS$FLUSH is still
  63. |>>being ignored.
  64. |>
  65. |>Have you actually tried this, or are you just making a wild-assed-guess without
  66. |>actually testing your claim?  The reason I ask is that your claim is dead wrong
  67. |>under VMS v5.4-2.  Perhaps it's different under a different version of VMS?
  68.  
  69. I was very careful to verify my assertions by experiment using DECC under
  70. AXP OpenVMS V1.0 before I wrote them up in my postings (I did the experiments
  71. on Alpha VMS, BTW, because somebody had asked Ehud about DECC's handling of
  72. this situation, and I happened to have an AXP system handy).  It works as I
  73. described using DECC on Alpha AXP VMS systems:  if the file is a PPF, RMS
  74. ignores the $FLUSH that is done by fsync().  However, in all cases, fsync()
  75. causes the C I/O buffers to be flushed.
  76.  
  77. I can believe that this is not the case under VAX/VMS V5.4-2.  The C I/O
  78. routines were completely rewritten for the DECC RTL, and many bugs and glitches
  79. such as this one were fixed.
  80.  
  81. --PSW
  82.