Last month we introduced a few functions that allow your applications to retrieve the current time from Linux. We discussed how one might implement a simple function that causes an application to wait for a specific amount of time before continuing execution. We also looked at the alarm() function, which keeps time for you, and how you might use alarm() instead of the timing functions to allow a program to wait for a specific amount of time without needlessly executing any instructions while waiting.
Last month we introduced a few functions that allow your applications to retrieve the current time from Linux. We discussed how one might implement a simple function that causes an application to wait for a specific amount of time before continuing execution. We also looked at the alarm() function, which keeps time for you, and how you might use alarm() instead of the timing functions to allow a program to wait for a specific amount of time without needlessly executing any instructions while waiting.
Our previous column started with two sections, “Getting the Time” and “Using the Time.” This month, we’ll again start with the same two topics, but instead of referring to the time functions we talked about previously, we’ll now take a look at how the Linux kernel itself deals with time.
Getting the Time
The fact that an operating system must deal closely with timing mechanisms is probably something overlooked by most computer users (and perhaps even most programmers!). We take for granted that we can simply get the time from our computers — after all, reading a clock should be easy for a sophisticated machine, right?
The answer to this question is less obvious than it first appears. Think about what you are looking for when you look at a clock. Essentially, you want to know approximately what time it is. Most of the time, it matters little to you whether it’s 12:04 or 12:06. A minute here or there doesn’t…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: