how can i go about keeping track of the system time ?
I guess i need to get the value from cmos somehow every so often and store it in a variable....maybe ever timer tick i dont know.
what are your thoughts ? does anyone have some sample of how this is done ?
system time
Re:system time
Yep, that's the right idea. On every IRQ0, increment some global variable. You could synchronise it every so often with the RTC time of day value to account for clock drift.
Re:system time
i was thinking maybe just read the time once on startup
i have my timer running at 100 ticks per second so once it has fired 100 times i increment my second counter......would this be accurate enough so that i wouldnt have to get the time from cmos every time the timer fires. I guess i could maybe check the cmos once a minute or so to compare the results and modify my time if it is off.
Also.....what frequency do you guys run your timer at ? Like i said, mine is at 100 Hz and what do you do in thar isr.....right now i only keep track of time elapsed since computer was started. When you start doing multi-tasking then I guess the code to change tasks would go in there. I know there needs to be a limit on how much code you put into the timer so that it can finish executing it by the time the next interrupt fires....i guess it really depends on the speed of the machine.
But I would still like an example of how to actually get the time and date from cmos.........google has turned up nothing so far
i have my timer running at 100 ticks per second so once it has fired 100 times i increment my second counter......would this be accurate enough so that i wouldnt have to get the time from cmos every time the timer fires. I guess i could maybe check the cmos once a minute or so to compare the results and modify my time if it is off.
Also.....what frequency do you guys run your timer at ? Like i said, mine is at 100 Hz and what do you do in thar isr.....right now i only keep track of time elapsed since computer was started. When you start doing multi-tasking then I guess the code to change tasks would go in there. I know there needs to be a limit on how much code you put into the timer so that it can finish executing it by the time the next interrupt fires....i guess it really depends on the speed of the machine.
But I would still like an example of how to actually get the time and date from cmos.........google has turned up nothing so far
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:system time
i have my clock at 1KHz, but most of the time, the handler do nothing but counting the ticks. The dispatcher (executive unit of the scheduler) for instance will wait 32 ticks before doing a switch in normal case, but it could do it earlier if some "urgent" thread has popped up ...
as machines now run about 1.000.000 instructions per millisecond, a few 200 cycles for an IRQ processing is only 0.02% of the CPU time -- which seems to be a very low overhead in my sense.
as machines now run about 1.000.000 instructions per millisecond, a few 200 cycles for an IRQ processing is only 0.02% of the CPU time -- which seems to be a very low overhead in my sense.
Re:system time
You could do this, but if you do, you'll find that the system time will drift slowly. Not only is the IRQ0 timer is less accurate than the RTC, but you'll find that you can't get an exact frequency from it. For example, it's not possible to get a frequency of precisely 100Hz. Therefore you'll need to correct the clock periodically (every minute? every ten seconds?).i was thinking maybe just read the time once on startup
Re:system time
i got my system time working just fine thanks guys......now my next step is writing a floppy drive device driver.......argh....
but that is in my other thread
but that is in my other thread