tags:

views:

141

answers:

3

Computers keep time normally with a built in clock on the motherboard. But out of curiosity, can a computer determine when a certain interval of time has passed?

I would think not as a computer can only execute instructions. Of course, you could rely on the computer knowing its own processing speed, but that would be an extremely crude hack that would take up way too many clock cycles and be error prone.

+3  A: 

Not without it constantly running to keep track of it, it pulling the time off of the internet constantly, or a piece of hardware to get the time from the constantly broadcast signal.

AaronM
+2  A: 

In certain cases, this is possible. Some microcontrollers and older processors execute their instructions in a defined time period, so by tracking the number of instructions executed, one can keep track of periods of time. This works well, and is useful, for certain cases (such as oscillating to play a sound wave), but in general, you're right, it's not particularly useful.

WhirlWind
+2  A: 

In the olden days there was a fixed timer interrupt. Often every 60th of a second in the US.

Old OS's simply counted these interrupts -- effectively making it a clock.

And, in addition to counting them, it also used this to reschedule tasks, thereby preventing a long-running task from monopolizing the procesor.

This scheme did mean that you had to set the time every time you turned the power on.

But in those days, powering down a computer (and getting it to reboot) was an epic task performed only by specialists.

I recall days when the machine wouldn't "IPL" (Initial Program Load) for hours because something was not right in the OS and the patches and the hardware.

S.Lott
1/60th of a sec, that's a jiffy!
Chris O
+1 for "in those days, powering down a computer...was an epic task"
Cam