November 2004
Intermediate to advanced
736 pages
14h 4m
English
Unix and Linux keep track of time in seconds before or after the epoch, which is defined as midnight, January 1, 1970 UTC.[1] Positive time values are after the epoch; negative time values are before the epoch. In order to provide processes with the current time, Linux, like all versions of Unix, provides a system call called time():
#include <time.h> time_t time(time_t *t);
time() returns the number of seconds since the epoch, and if t is non-null, it also fills in t with the number of seconds since the epoch.
Some problems require higher resolution. Linux provides another system call, gettimeofday(), which provides more information:
#include <sys/time.h> #include <unistd.h> int gettimeofday(struct ...