clock

What is the effect of changing system time on sleeping threads?

梦想的初衷 提交于 2019-12-01 02:56:55
问题 If you take a look at the clock_gettime() function, which is available in all BSDs and is actually defined as part of the POSIX standard, you see that there is support for at least three types of clocks (many systems support more than these clocks, but actually the POSIX standard only demands one to be present, all others are optional): CLOCK_REALTIME - POSIX demands this to be present. This is the wall time clock. CLOCK_MONOTONIC - No idea what this is (and what SI seconds mean), but I

Clock in different time zones

元气小坏坏 提交于 2019-12-01 02:55:51
问题 I am trying to create two clocks on a website that says two times on it. One from London and the other from New York. I have been able to create a clock that reads the current time on my computer but i'm not sure how to place a time zone into this. The code I have so far is: <script type="text/javascript" language="javascript"> function renderTime() { var currentTime = new Date(); var diem = "AM"; var h = currentTime.getHours(); var m = currentTime.getMinutes(); var s = currentTime.getSeconds

iOS how to detect user has changed system time, and if not compare device time with server time

[亡魂溺海] 提交于 2019-12-01 00:30:35
The requirement is that have to detect if the system time of iPhone is changed by user manually. For that I have used NSNotificationCenter.defaultCenter().addObserver(self, selector: "timeChangedNotification:", name: NSSystemClockDidChangeNotification, object: nil) and func timeChangedNotification(notification:NSNotification){ println("Device time has been changed...") } But not getting the results. Also if this time is not changed means it is automatic time provided by network then have to compare with server time.How can this be done? Please give help for the same. As per its documentation,

Calculating number of seconds between two points in time, in Cocoa, even when system clock has changed mid-way

本小妞迷上赌 提交于 2019-11-30 18:41:10
I'm writing a Cocoa OS X (Leopard 10.5+) end-user program that's using timestamps to calculate statistics for how long something is being displayed on the screen. Time is calculated periodically while the program runs using a repeating NSTimer. [NSDate date] is used to capture timestamps, Start and Finish . Calculating the difference between the two dates in seconds is trivial. A problem occurs if an end-user or ntp changes the system clock. [NSDate date] relies on the system clock, so if it's changed, the Finish variable will be skewed relative to the Start , messing up the time calculation

Running time of functions

浪尽此生 提交于 2019-11-30 18:14:46
问题 I am wanting to print the running time of my functions. For some reason my timer always returns 0. Can anyone tell me why? double RunningTime(clock_t time1, clock_t time2) { double t=time1 - time2; double time = (t*1000)/CLOCKS_PER_SEC; return time; } int main() { clock_t start_time = clock(); // some code..... clock_t end_time = clock(); std::cout << "Time elapsed: " << double(RunningTime(end_time, start_time)) << " ms"; return 0; } I attempted to use gettimeofday and it still returned 0.

Small footprint clock synchronization without NTP

允我心安 提交于 2019-11-30 17:31:36
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 clear, I'm not looking for something that can be used just to order events (like vector clocks), but something that would enable processes on different nodes to synchronize their actions based on local clocks. As far as I understand, this would require a solution that can take clock drift into account. Presence of TCP/IP or similar relatively low-latency

javascript countdown clock

一世执手 提交于 2019-11-30 16:44:11
<script> var interval; var minutes = 1; var seconds = 5; window.onload = function() { countdown('countdown'); } function countdown(element) { interval = setInterval(function() { var el = document.getElementById(element); if(seconds == 0) { if(minutes == 0) { el.innerHTML = "countdown's over!"; clearInterval(interval); return; } else { minutes--; seconds = 60; } } if(minutes > 0) { var minute_text = minutes + (minutes > 1 ? ' minutes' : ' minute'); } else { var minute_text = ''; } var second_text = seconds > 1 ? 'seconds' : 'second'; el.innerHTML = minute_text + ' ' + seconds + ' ' + second

Small footprint clock synchronization without NTP

百般思念 提交于 2019-11-30 16:39:45
问题 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 clear, I'm not looking for something that can be used just to order events (like vector clocks), but something that would enable processes on different nodes to synchronize their actions based on local clocks. As far as I understand, this would require

How can I measure time in Java not susceptible to System clock changes?

回眸只為那壹抹淺笑 提交于 2019-11-30 16:04:20
I would like to measure elapsed time in a Java. However differences in System.currentTimeMillis() and (I believe) System.nanoTime() can be changed by external changes eg someone (or the system) altering the system clock. Using network calls is not an option as it's possible very frequent and fast returns are required. Is there a common solution for this? EDIT Sorry, I should have elaborated about the reason. It isn't to stop malicious users - it's things like client initiated logout for being idle and routine client events. Cowan This doesn't really answer your question, but bug #6458294

VHDL: creating a very slow clock pulse based on a very fast clock

和自甴很熟 提交于 2019-11-30 14:23:32
(I'd post this in EE but it seems there are far more VHDL questions here...) Background: I'm using the Xilinx Spartan-6LX9 FPGA with the Xilinx ISE 14.4 (webpack). I stumbled upon the dreaded "PhysDesignRules:372 - Gated clock" warning today, and I see there's a LOT of discussion out there concerning that in general. The consensus seems to be to use one of the DCMs on the FPGA to do clock division but... my DCM doesn't appear to be capable of going from 32 MHz to 4.096 KHz (per the wizard it bottoms out at 5MHz based on 32MHz... and it seems absurd to try to chain multiple DCMs for this low