1

I want to know is there any way to change Windows or Linux clock rate or the system clock rate (maybe via BIOS)? I mean accelerate or decelerate system clock!

For example every 24 hours in the computer lasts 12 hours or 36 hours in real!!!

NOTE :

Using the below batch file, I can decelerate Windows time. But I want something in a lower level! I want to change clock pace in a way that all time for all the programs and tool be slower or faster! not only Windows time!

@echo off

:loop

set T=%time%
timeout 1
time %T%
timeout 1

goto loop
TheGoodUser
  • 1,188
  • 4
  • 26
  • 52
  • 1
    Write a program that every second adjusts the system time forward a second or back a quarter of a second. – Ross Ridge Aug 15 '14 at 20:09
  • I already did it with a batch file! but I want something better! I mean in a lower level! If I write a program that every second adjusts the system time forward a second or back a quarter of a second, another program that call time API, works normally! I want to change somthing in the OS in a way that time changes for all the other program and tools too! – TheGoodUser Aug 15 '14 at 20:15
  • 1
    This is an interesting question. NTPd supports gradual slew, but normally on the order of 0.5%, not 50%. Maybe `adjtimex(2)` can be used/abused for this, along with some disabled sanity checks in the kernel source? – that other guy Aug 15 '14 at 20:17
  • 1
    The system time is global, so changing it will be immediately effective in any other process that requests the current system. Either your batch file isn't changing the system time or the other processes don't change their behaviour because they're not querying the system time. – Ross Ridge Aug 15 '14 at 20:18
  • @RossRidge I added a batch file to the question. Do you think this batch file can change clock rate for the other programs also? or it only change time of windows?! – TheGoodUser Aug 15 '14 at 20:33
  • @thatotherguy would you please explain more? I didn't understand! What is `adjtimex(2)`? Is it for Linux? – TheGoodUser Aug 15 '14 at 20:35
  • If you want to slow down or speed up other processes than that's a different question. Most processes do not base the speed they do things on the system time of day. What other processes are you trying to slow down or speed up and why? – Ross Ridge Aug 15 '14 at 20:37
  • **Why do you ask**? It is a strange thing to do. – Basile Starynkevitch Aug 15 '14 at 20:47
  • It might be possible to modify one of the open source VM solutions to do this (to the VM). – Harry Johnston Aug 17 '14 at 00:46

2 Answers2

2

So your CPU's clock is not actually programmable via system calls. It's actually working off of an oscillator w/ crystal. You cannot change during booting up. This is done intentionally so that your CPU is able time regardless of your power/wifi/general system status.

Devarsh Desai
  • 5,984
  • 3
  • 19
  • 21
1

As commented by That Other Guy you might perhaps use adjtimex(2) syscall, but you first should be sure that no NTP client daemon -which uses adjtimex- is running (so stop any ntpd or chrony service).

I'm not sure it would work, and it might make your system quite unstable.

A more rude possibility might be to forcibly set the date(1) -or also hwclock(8)- quite often (e.g. in some crontab job running every 5 minutes).

I believe it (i.e. decelerating a lot the system clock) is a strange and bad thing to do. Don't do that on a production machine (or even on some machine doing significant requests on the Web). Be prepared to perhaps break a lot of things.

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547