Section 19.3. System Time Facilities


19.3. System Time Facilities

19.3.1. High-Resolution Timer

The kernel also maintains a high-resolution timer for nanosecond-level timing functions. On UltraSPARC-based systems, the hardware TICK register is used; it is incremented with every processor clock tick, that is, every 2.5 nanoseconds on a 400 MHz processor. An internal getHRestime() (get high-resolution time) function is used in a few areas of the kernel where fine-grained time is needed, such as the support for real-time interval timers (the setitimer(2) system call with the ITIMER_REAL flag). A gethrtime(3C) interface provides programs with nanosecond-level granularity for timing. The getHRtime(3C) function has an optimized code path to read the TICK register and return a normalized (converted to nanoseconds) value to the calling program.

19.3.2. Time-of-Day Clock

All computer systemsfrom desktop PCs to high-end multiprocessor systemshave a clock circuit of some sort. SPARC-based systems include clock circuitry in the EEPROM area of the hardware (for example, the Mostek 48T59 clock chip is used on UltraSPARC-based systems). This time-of-day (TOD) clock chip is addressable by the kernel as part of the firmware address space and has a hardware register specification; a kernel interface to the TOD hardware is implemented as a TOD device driver.

The chip itself implements several registers, readable and writable by the kernel through the device driver, that provide multiple counters for the numeric components that make up the date and time (for example, minute-of-the-hour, hour-ofthe-day, day-of-the-week, month-of-the-year).

Figure 19.3 illustrates the hardware and software hierarchy for the TOD. Each component of a day and time value is stored as a separate counter value in the clock chip, and each counter increments the next logical value when it reaches its top value; for example, seconds count values 059, then increment minutes and restart at 0. Executing the date(1) command to set the date calls the stime(2) system call, which in turn calls the tod_set() device driver interface that sets the values in the TOD clock hardware.

Figure 19.3. Example Time-of-Day Clock Stack


To comply with industry-standard interfaces (system calls and library routines), the kernel provides functions for converting the date values read from the clock hardware to the UNIX convention of the number of seconds since the epoch, and vice-versa.




SolarisT Internals. Solaris 10 and OpenSolaris Kernel Architecture
Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture (2nd Edition)
ISBN: 0131482092
EAN: 2147483647
Year: 2004
Pages: 244

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net