Page 1 of 1

how to access system time? i am writing my own OS

Posted: Wed Feb 01, 2012 4:32 am
by hegde1997
For my OS i want to display time, date etc. so where will be the system time and how to access it?

Re: how to access system time? i am writing my own OS

Posted: Wed Feb 01, 2012 4:39 am
by Solar
If you click on the "The OSDev.org Wiki" link above, you will find a chapter with the header "Clocks, Timers and Counters".

Re: how to access system time? i am writing my own OS

Posted: Wed Feb 01, 2012 6:17 am
by Brendan
Hi,
hegde1997 wrote:For my OS i want to display time, date etc. so where will be the system time and how to access it?
Solar wrote:If you click on the "The OSDev.org Wiki" link above, you will find a chapter with the header "Clocks, Timers and Counters".
Yes.

Also note that normally you only get the system time from hardware once during boot (either from the RTC or via. a UEFI function), and convert into something like UTC or TAI. After that you maintain your own version of the date and time, typically in an "integer ticks since the epoch" format, using the PIT or HPET or something to measure the (very small) "ticks". This can also mean converting it from your standard representation into "local time wherever the end user happens to be" if/when necessary (and for multi-user systems where people log in remotely, can mean different users in different time zones need to have a different "local time"), including handling things like daylight savings rules for each region.


Cheers,

Brendan