Questions tagged [clock]

Hardware and system clocks used by drivers, OS and hardware languages.

Clocks are key to controlling synchronous logic and are used by drivers, and OS software. As well, hardware languages, such as and can make extensive use of clocks. CPU or system clocks are familiar to most developers, but a typical computer can contain many different clocks to control different hardware functions such as video, audio, RAM, buses, etc. Familiar current time functions are often derived from a hardware clock which produces interrupts allowing an OS to keep a running time count by recording the interrupt; sometimes called ticks or jiffies.

Related tags

  • - obtaining, formatting times and other uses.
  • - program issues dealing with dates.
  • - measuring execution time with a clock.

See also: PLL, Clock divider

2060 questions
16
votes
2 answers

Setting system time in rspec tests without changing system clock

I'm working on getting a rails 3 application ready to use time zones. My development machine is in EDT and the servers I'm hosting on are in UTC. Is there a way in my rspec tests to change the system time zone ruby is using so that I'm running…
Dan Caddigan
  • 1,578
  • 14
  • 25
16
votes
13 answers

Clock drift on Windows

I've developed a Windows service which tracks business events. It uses the Windows clock to timestamp events. However, the underlying clock can drift quite dramatically (e.g. losing a few seconds per minute), particularly when the CPUs are working…
Matt Howells
  • 40,310
  • 20
  • 83
  • 102
15
votes
2 answers

How to make pthread_cond_timedwait() robust against system clock manipulations?

Consider the following source code, which is fully POSIX compliant: #include #include #include #include #include #include int main (int argc, char ** argv) { pthread_cond_t c; …
Mecki
  • 125,244
  • 33
  • 244
  • 253
15
votes
6 answers

Small footprint clock synchronization without NTP

I'm looking for a simple clock synchronization protocol that would be easy to implement with small footprint and that would work also in the absence of internet connection, so that it could be used e.g. within closed laboratory networks. To be…
Antti Huima
  • 25,136
  • 3
  • 52
  • 71
15
votes
2 answers

Why is clock() considered bad?

I was once advised to use a platform dependent method (GetTickCount() for Windows) for getting time instead of using clock(), because it's bad or unreliable. Why? There's also this header functions that many suggest, however, I can't find…
McLovin
  • 3,295
  • 7
  • 32
  • 67
14
votes
8 answers

Clock on webpage using server and system time?

I need to add a clock to a web page. The clock needs to be synchronized with a server but I really don't want to have it constantly check the server as the page will be open 24/7 on several PCs. Is there some way to get the time from the server and…
Shawn
  • 2,356
  • 6
  • 48
  • 82
14
votes
4 answers

Can I prevent an iOS user from changing the date and time?

I want to deploy managed iOS devices to employees of the company, and the app they will use will timestamp data that will be recorded locally, then forwarded. I need those timestamps to be correct, so I must prevent the user from adjusting the time…
Dave MacLean
  • 5,163
  • 2
  • 22
  • 31
14
votes
5 answers

How Do You Programmatically Set the Hardware Clock on Linux?

Linux provides the stime(2) call to set the system time. However, while this will update the system's time, it does not set the BIOS hardware clock to match the new system time. Linux systems typically sync the hardware clock with the system time…
Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302
13
votes
1 answer

AlarmClock for Beginners - Android

I'm quite new to Android but already have some experience with Java itself. Now I'd like to set up an App that asks for time and date and then sets up an alarm clock. I already looked through the google apis and lots of other stuff, but either I…
michaelbahr
  • 4,837
  • 2
  • 39
  • 75
13
votes
2 answers

How do I establish clock synchronization in the cloud (AWS, heroku, etc) across many nodes?

I would like to run a large cluster of nodes in the cloud (AWS, Heroku, or maybe self-manged VMS), whose clocks must be synchronized with a predefined tolerance in mind. I'm looking for a tolerance of maybe 200 ms. That means if I have 250 nodes,…
Bernie Habermeier
  • 2,580
  • 2
  • 22
  • 20
13
votes
2 answers

Android timer that works when device is sleeping

I'm writing a sports app that needs to track the elapsed time of quarter/half/period. Elapsed time needs to be accurate to the second. The game clock needs to continue to run even if the user explicitly places the device in sleep mode by pressing…
Rich
  • 201
  • 3
  • 9
13
votes
2 answers

Heroku clock process: how to ensure jobs weren't skipped?

I'm building a Heroku app that relies on scheduled jobs. We were previously using Heroku Scheduler but clock processes seem more flexible and robust. So now we're using a clock process to enqueue background jobs at specific times/intervals. Heroku's…
oregontrail256
  • 657
  • 1
  • 6
  • 14
13
votes
7 answers

How do I display time in 24-hour format using a TextClock?

I am having trouble trying to get a time to display in 24-hour format. I have got it to display the time in another time zone but I can't get it to display in 24-hour format.
littledevils326
  • 689
  • 3
  • 11
  • 19
13
votes
3 answers

Makefile : Clock skew detected

My problem is whenever I try to compile using Makefile I get the following : make: Warning: File `Board.c' has modification time 1.3e+03 s in the future gcc -Wall -c -Wvla -lm Board.c -o Board.o gcc -Wall -c -Wvla -lm PlayBoard.c -o PlayBoard.o gcc…
Nadin Haddad
  • 337
  • 2
  • 3
  • 9
12
votes
7 answers

why C clock() returns 0

I've got something like this: clock_t start, end; start=clock(); something_else(); end=clock(); printf("\nClock cycles are: %d - %d\n",start,end); and I always get as an output "Clock cycles are: 0 - 0" Any idea why this happens? (Just to give…
eddy ed
  • 917
  • 2
  • 10
  • 21