System clock for dual boot and writing to RTC

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
shahsunny712
Posts: 20
Joined: Wed Jan 29, 2014 11:57 am

System clock for dual boot and writing to RTC

Post by shahsunny712 »

I have been reading the osdev and other online articles on RTC and the system clock. The whole thing seems quite confusing to me, but the mist is slowly beginning to clear.

I have a few questions that'll be immensely helpful in further reading:
- Linux assumes RTC is in UTC, while Windows assumes its in local time. Is this correct ?
- If the above is true, how do Ubuntu and Windows on my machine(dual-boot) show the time correctly ? I don't have the "RealTimeIsUniversal" regsitry key set in Windows, and I don't remember doing any changes in in this regard in Linux.
- Do operating systems make any changes to the time in the RTC ? If yes, how often ? Do they write the UTC or localtime ? (I read some things about syncing using NTP, but couldn't really understand it)
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: System clock for dual boot and writing to RTC

Post by FallenAvatar »

Is this a purely educational question? (ie. just for your own understanding) A Homework Question? (Doesn't seem likely) Or is there an actual problem you are trying to solve?

- Monk
shahsunny712
Posts: 20
Joined: Wed Jan 29, 2014 11:57 am

Re: System clock for dual boot and writing to RTC

Post by shahsunny712 »

Sorry, I should have added - I was understanding how to read from the CMOS to show the time in my OS. It is from the CMOS page that I landed on several different pages, and would like to understand this before implementing the time functionality. It'll also be useful in knowing how different OSes function, and what design I should choose.
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: System clock for dual boot and writing to RTC

Post by alexfru »

The traditional PC RTC does not have any internal register for time zone or geographic location (nor does it have a built-in GPS or something like that). Have you ever installed Windows or Ubuntu? When you install the OS you provide this info to the OS manually. From that point on the OS knows how to translate time. Unless, of course, you travel or your government decides to change either the time zone offset or the daylight saving times at which point a mechanism is needed to find out about it and take the change into account. OS updates can bring that legal info in or you can do the adjustments manually.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: System clock for dual boot and writing to RTC

Post by Brendan »

Hi,
shahsunny712 wrote:- Linux assumes RTC is in UTC, while Windows assumes its in local time. Is this correct ?
Yes, mostly. However Linux does support "RTC set to local time" and (modern) Windows supports "RTC set to UTC" - it's just the default assumptions that are different.
shahsunny712 wrote:- Do operating systems make any changes to the time in the RTC ? If yes, how often ? Do they write the UTC or localtime ? (I read some things about syncing using NTP, but couldn't really understand it)
That depends on the OS and how it's configured. For example, the computer I'm using at the moment is configured to use NTP and to update the RTC's time and date when the OS shuts down (but I could've configured it differently). I'm not sure what Windows does.

Note that (excluding compatibility reasons) the only sane option is to use UTC for the RTC. If you use local time then (without relying on NTP instead of relying on RTC) it's impossible to prevent breakage caused by daylight savings changes when there are 2 or more OSs installed, as no OS will know who is responsible for updating the RTC and they will all do it, leading to "wrong by (number of OSs - 1) hours" twice per year.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
shahsunny712
Posts: 20
Joined: Wed Jan 29, 2014 11:57 am

Re: System clock for dual boot and writing to RTC

Post by shahsunny712 »

Brendan wrote: Yes, mostly. However Linux does support "RTC set to local time" and (modern) Windows supports "RTC set to UTC" - it's just the default assumptions that are different.

That depends on the OS and how it's configured. For example, the computer I'm using at the moment is configured to use NTP and to update the RTC's time and date when the OS shuts down (but I could've configured it differently). I'm not sure what Windows does.
So let's say I have Linux installed and everything's working fine (RTC=UTC, time in Linux=local time).

Now I install Windows. I don't remember the installation steps, but I think we had to specify the timezone. Will Windows consider the time detected at this stage as local time, even though it actually is UTC ? If I correct the time, will it change anything in RTC or only in the OS ?

Also, when I update the time in any OS, is it correct that that changes only the system clock and not the RTC ?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: System clock for dual boot and writing to RTC

Post by Combuster »

Also, when I update the time in any OS, is it correct that that changes only the system clock and not the RTC ?
Knowing that my system time is always wrong whenever I (accidentally) boot into windows, at least one OS is consistently writing it.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply