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

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.
Locked
User avatar
hegde1997
Member
Member
Posts: 40
Joined: Mon Jan 30, 2012 7:36 am
Location: Bangalore, India
Contact:

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

Post by hegde1997 »

For my OS i want to display time, date etc. so where will be the system time and how to access it?
Walking my way in making my OS
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

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

Post 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".
Every good solution is obvious once you've found it.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

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

Post 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
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.
Locked