[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

curtime Kernel Service


Reads the current time into a time structure.


#include <sys/types.h>
#include <sys/errno.h>
#include <sys/time.h>
void curtime (timestruct)
struct timestruc_t *timestruct;


timestruct Points to a timestruc_t time structure defined in the /usr/include/sys/time.h file. The curtime kernel service updates the fields in this structure with the current time.


The curtime kernel service reads the current time into a time structure defined in the /usr/include/sys/time.h file. This service updates the tv_sec and tv_nsec fields in the time structure, pointed to by the timestruct parameter, from the hardware real-time clock. The kernel also maintains and updates a memory-mapped time tod structure. This structure is updated with each clock tick.

The kernel also maintains two other in-memory time values: the lbolt and time values. The three in-memory time values that the kernel maintains (the tod, lbolt, and time values) are available to kernel extensions. The lbolt in-memory time value is the number of timer ticks that have occurred since the system was booted. This value is updated once per timer tick. The time in-memory time value is the number of seconds since Epoch. The kernel updates the value once per second.

Note: POSIX 1003.1 defines "seconds since Epoch" as a "value interpreted as the number of seconds between a specified time and the Epoch". It further specifies that a "Coordinated Universal Time name specified in terms of seconds (tm_sec), minutes (tm_min), hours (tm_hour), and days since January 1 of the year (tm_yday), and calendar year minus 1900 (tm_year) is related to a time represented as seconds since the Epoch, according to the following expression: tm_sec + tm_min * 60 tm_hour*3600 + tm_yday * 86400 + (tm_year - 70) * 31536000 ((tm_year - 69) / 4) * 86400 if the year is greater than or equal to 1970, otherwise it is undefined."

The curtime kernel service does not page-fault if a pinned stack and input time structure are used. Also, accessing the lbolt, time, and tod in-memory time values does not cause a page fault since they are in pinned memory.

Execution Environment

The curtime kernel service can be called from either the process or interrupt environment.

The tod, time, and lbolt memory-mapped time values can also be read from the process or interrupt handler environment. The timestruct parameter and stack must be pinned when the curtime service is called in an interrupt handler environment.

Return Values

The curtime kernel service has no return values.

Implementation Specifics

The curtime kernel service is part of Base Operating System (BOS) Runtime.

Related Information

Timer and Time-of-Day Kernel Services in AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts.

[ Previous | Next | Contents | Home | Search ]