A/UX 2.0 ftime() and open()

I am doing some A/UX 2.0 benchmarks and am having problems in two areas that
involve C code. First, I need the equivalent of the ftime function on a Sun
for timing execution time. The second is how to do a synchronous write to
disk. The usual "write (o_sync)" command doesn't seem to be working.


1) As far as we can tell, the ftime() function call that appears in most BSD
  UNIX systems (including Sun UNIX) is obsolete and now replaced by the
  gettimeofday() function call.  A/UX has gettimeofday() but not ftime().

  From the structure returned by ftime() and the new structures used by
  gettimeofday(), it should not be difficult to use the new gettimeofday()
  instead of the obsoleted ftime().  The structure returned by ftime() is
  defined in <sys/timeb.h> of BSD UNIX as:

          struct  timeb
          {
               time_t          time;
               unsigned short  millitm;
               short           timezone;
               short           dstflag;
          };

The structures used by gettimeofday() are defined in <sys/time.h> as:

          struct timeval {
               long   tv_sec;    /* seconds since Jan. 1, 1970 */
               long   tv_usec;   /* and microseconds */
          };

          struct timezone {
               int   tz_minuteswest; /* Greenwich */

               int   tz_dsttime;     /* type of dst correct to apply */
          };

2) To do a synchronous write to DISK, the fsync (2) system call should be
  used after the write(2) or writev (2) system call.  The fsync (2) system
  call causes all in-core copies of buffers for the associated file to be
  written to a DISK.  See fsync (2) manual page for more information.

Note that the use of the O_NDELAY and O_NONBLOCK flags in the open() system
call for controlling I/O applies only to FIFOs and communication lines like
tty's.  See open (2) manual pages for more information.


Published Date: Feb 18, 2012