CLK_TCK vs. CLOCKS_PER_SEC

Moderator, John S. Quarterman std-unix at longway.TIC.COM
Mon Mar 20 14:28:27 AEST 1989


From: uunet!BRL.MIL!gwyn

In article <320 at longway.TIC.COM> uunet!mcgrath at paris.Berkeley.EDU@ (Roland McGrath) writes:
>Can anyone tell me why the ANSI C committee changed CLK_TCK to
>CLOCKS_PER_SEC, and how this is supposed to be different than the CLK_TCK
>that 1003.1 assumes the C standard defines?

In fact they have totally different uses, and X3J11 had made a serious
mistake when we used the name "CLK_TCK" for the clock()-return conversion
factor.  CLK_TCK was the 1984 /usr/group macro for  converting values
returned by times(), not clock().  1003.1 shuffled back and forth a couple
of times between ttime_t and clock_t as the type of the struct tms members,
settling on clock_t which is defined by ANSI C.  (I think a separate type
would have been better, but we can live with this.)  Then when they saw that
X3J11 had defined CLK_TCK as the appropriate conversion from units of clock_t
to seconds, they naturally assumed it was the same as the 1984 /usr/group
usage.  However, the ANSI C clock() conversion macro was not appropriate for
use with struct tms members.  Last-minute frantic coordination among principal
members of P1003 and X3J11, including the ANSI C draft review subcommittee,
resulted in X3J11 choosing a new name for the ANSI C time-conversion macro;
we considered that a (borderline) "editorial change", since the intention of
the committee was clearly not changed and the use of "CLK_TCK" for clock()
units conversion was purely an X3J11 invention.  This means that the
inheritance of the name "CLK_TCK" from <time.h> that 1003.1 expected doesn't
happen (at least, not in the absence of _POSIX_SOURCE), but that was
considered to be an "easily fixable" matter whereas forcing the same
conversion factor for both times() and clock() would have run counter to
widespread existing practice.
	- D A Gwyn
	acting X3J11/P1003 liaison

Volume-Number: Volume 16, Number 22



More information about the Comp.std.unix mailing list