Questions tagged [system-clock]

130 questions
35
votes
6 answers

Why is CLOCKS_PER_SEC not the actual number of clocks per second?

I have just written this short C++ program to approximate the actual number of clock ticks per second. #include #include using namespace std; int main () { for(int i = 0; i < 10 ; i++) { int first_clock =…
Kevin H. Lin
  • 1,238
  • 3
  • 14
  • 16
23
votes
5 answers

Time since first boot up

I'm developing an android application and hit the problem with determining system first boot up time. I mean i need to measure how much time already passed from device first boot up. I know about solution with listening for ACTION_BOOT_COMPLETED and…
user2857033
  • 339
  • 4
  • 6
22
votes
6 answers

JavaScript setTimeout and changes to system time cause problems

I've noticed that if I set the setTimeout for 1 minute in the future, and then change my system time to 5 minutes in the past, the setTimeout function will trigger in 6 minutes. I did this is because I wanted to see what happens during a daylight…
Martin Konecny
  • 57,827
  • 19
  • 139
  • 159
21
votes
3 answers

Is there an NTP server I should be using when using Amazon's EC2 service to combat clock drift?

I’m using AWS and am on an EC2 server … [dalvarado@mymachine ~]$ uname -a Linux mydomain.org 3.14.33-26.47.amzn1.x86_64 #1 SMP Wed Feb 11 22:39:25 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux My clock is off by a minute ro so despite the fact that I…
Dave A
  • 2,780
  • 9
  • 41
  • 60
20
votes
4 answers

How do I deal with the system clock changing while waiting on a std::condition_variable?

I'm trying to implement some cross-platform code in C++11. Part of this code implements a semaphore object using a std::condition_variable. When I need to do a timed wait on the semaphore, I use wait_until or wait_for. The problem I'm experiencing…
jldeon
  • 363
  • 2
  • 11
18
votes
1 answer

Set Android's date/time programmatically

I need set the date/time from Android programmatically, but I'm not having success! I have these three sources above: Source code 1 AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE); alarm.setTime(1330082817000);…
eliangela
  • 253
  • 2
  • 5
  • 21
14
votes
2 answers

Monotonically increasing time in Node.js

This question has already been answered for the browser here, but window.performance.now() is obviously not available in Node.js. Some applications need a steady clock, i.e., a clock that monotonically increases through time, not subject to system…
Lucio Paiva
  • 19,015
  • 11
  • 82
  • 104
11
votes
1 answer

What does it mean by "partial ordering" and "total ordering" in the discussion of Lamport's synchronization Algorithm?

What I understand is, partial ordering and total ordering are two sets of rules. Partial ordering has Three rules: (1) if a an b are two events in the same process and a comes before b, then a->b. (2) ... (3) ... What is total ordering…
user366312
  • 16,949
  • 65
  • 235
  • 452
10
votes
1 answer

Accuracy of clock() function in C

I have some code that tries to determine the execution time of a code block. #include #include int main() { clock_t start_t, end_t, total_t; int i; start_t = clock(); //clock start printf("Starting of the program,…
user2808264
  • 459
  • 2
  • 11
  • 24
10
votes
2 answers

Android - Get current time without dependency on device's clock

I've noticed that System.currentTimeMillis() time is device dependent. If I change the time on the device's clock, this method will return a different answer. For example: If the real time now is 10:00, and I change the clock on my device to 9:30,…
Aviv Ben Shabat
  • 1,073
  • 2
  • 13
  • 33
8
votes
2 answers

How to get Android system uptime and realtime from command line?

I'm writing a script containing several "adb shell" command. I also want to record the time when program execute these command in a form of realtime and uptime. I know I can get uptime and realtime through…
Wei Yang
  • 895
  • 3
  • 15
  • 26
7
votes
2 answers

What should Timertask.scheduleAtFixedRate do if the clock changes?

We want to run a task every 1000 seconds (say). So we have timer.scheduleAtFixedRate(task, delay, interval); Mostly, this works fine. However, this is an embedded system and the user can change the real time clock. If they set it to a time in the…
The Archetypal Paul
  • 41,321
  • 20
  • 104
  • 134
6
votes
1 answer

Is `System.currentTimeMillis()` correct across multiple processes?

We have a situation where a master process writes to a log. It then spawns multiple worker processes which write to their own logs. (I wanted the workers to log through the master, but there was resistance to this idea for some reason.) What I want…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
6
votes
2 answers

Android: How to convert from SystemClock.elapsedRealTime to a human readable CharSeq?

How do you convert from SystemClock.elapsedRealTime() to a human readable CharSeq that can be displayed in textview?
user3472351
  • 99
  • 1
  • 2
  • 6
6
votes
3 answers

Increasing the speed of qemu clock

I'm trying to increase the speed at which qemu runs, so for example one tick of the real CPU will correspond to two ticks of the virtual time of qemu. Is this possible and if so does anyone have any pointers on how to go about doing this?
mwray
  • 61
  • 1
  • 1
  • 3
1
2 3
8 9