简体   繁体   English

更改系统时间会使应用程序挂起LINUX(LUBUNTU)TCL / TK

[英]Changing system time causes application to hang LINUX (LUBUNTU) TCL/TK

I have a tcl/tk with c desktop application, and one of the requirements is to change the system time, in the background there are threads running from the c code, and "after" commands from the tcl code. 我有一个带有c桌面应用程序的tcl / tk,其中一项要求是更改系统时间,在后台有一些从c代码运行的线程,以及从tcl代码运行的“ after”命令。 Whenever I change the time to an earlier time the system hangs ie: 05:50:12 -> 05:45:12 also i get weird behavior when going forward in time. 每当我将时间更改为较早的时间时,系统就会挂起,即: 05:50:12 : 05:50:12 : 05:50:12 > 05:45:12当我按时间前进时,我也会得到奇怪的行为。 I'm running lubuntu. 我正在运行lubuntu。 I'm not sure what to do in this situation, I made some test and it seems the after keeps on waiting after i change back in time. 我不确定在这种情况下该怎么做,我做了一些测试,在我及时改变时间之后,之后一直在等待。

to change the time i use : exec date --set="STRING" from the tcl code 更改我使用的时间:tcl代码中的exec date --set="STRING"

Tcl depends on the system time (converted to seconds from the start of the Unix epoch) increasing fairly close to monotonically for the correct behaviour of a number of things, but most particularly anything in the after command. Tcl取决于系统时间(从Unix纪元开始转换为秒),对于许多事物的正确行为(尤其是after命令中的任何事物)的正确行为,其增加与单调相当接近。 Internally, after computes the absolute time that an event should happen and only triggers things once that time is reached, so that things being triggered early (which can happen because of various OS events) don't cause problems. 在内部, after计算的绝对时间的事件应该发生,仅一旦达到该时间触发一些东西,这样的事情都是早触发(可由于各种操作系统事件都发生),不会产生问题。 If you set the system time back a long way, Tcl will wait until the absolute time is reached anyway, which will look a lot like a hang. 如果您将系统时间设置得很长,Tcl将一直等到绝对时间到达为止,这看起来很像死机。

Just synch your clock with NTP (ie, switch on ntpd ) and stop fiddling with the system clock by hand. 只需将您的时钟与NTP同步(即,打开ntpd ),然后停止手动摆弄系统时钟即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM