William Breathitt Gray
William Breathitt Gray

Reputation: 11986

C99 definition of "processor time"

Section 7.23.1 paragraph 1 of the C99 standard defines several "time" terms:

Many functions deal with a calendar time that represents the current date (according to the Gregorian calendar) and time. Some functions deal with local time, which is the calendar time expressed for some specific time zone, and with Daylight Saving Time, which is a temporary change in the algorithm for determining local time. The local time zone and Daylight Saving Time are implementation-defined.

However, the definition of "processor time" is missing.

Section 7.23.2.1 paragraph 2 of the C99 states:

The clock function determines the processor time used.

What is "processor time?" Is "processor time" defined within the C99 standard; if so, where is it defined?

Upvotes: 0

Views: 154

Answers (2)

Keith Thompson
Keith Thompson

Reputation: 263477

The standard doesn't define the phrase "processor time". It uses it in its normal technical English sense.

The standard includes a list of normative references in section 2, one of which is:

  • ISO/IEC 2382−1:1993, Information technology — Vocabulary — Part 1: Fundamental terms.

If that document defined "processor time", then that's the definition used by the standard. I don't know whether it does or not, since I don't have access to that document.

But the idea is that "processor time" is the amount of type used by the CPU, which excludes time spent sleeping or waiting for some event such as the completion of an I/O request. For example, a program that reads a line of input from the keyboard might consume, say, 60 seconds of "wall-clock time" (if the user takes that long to respond), but only a fraction of a second of processor time. Usually elapsed processor time will be less than elapsed "wall clock" time, but it might be greater if the program runs on multiple CPUs.

Incidentally, this wording has not changed significantly across C90, C99, and C11.

Upvotes: 1

Tommy
Tommy

Reputation: 100632

Per 7.23.1:

The header < time.h > defines two macros ... NULL (described in 7.17); and

CLOCKS_PER_SEC

which expands to a constant expression with type clock_t (described below) that is the number per second of the value returned by the clock function.

Therefore processor time must mean a clock_t value measured in CLOCKS_PER_SEC, given that the spec defines that as the result of a call to clock and elsewhere uses the term 'processor time' as the name for that result.

Upvotes: 0

Related Questions