Bochs RTC , Qemu PIT Problems
-
- Member
- Posts: 29
- Joined: Wed Jan 25, 2012 2:37 pm
Bochs RTC , Qemu PIT Problems
While developing my kernel's clock, I noticed an interesting problem:
When I read from Bochs' RTC, it shows the time much faster than it really is.
When I use qemu's PIT, it is slower than Bochs'
Maybe I'm not configuring something?
Thanks!
When I read from Bochs' RTC, it shows the time much faster than it really is.
When I use qemu's PIT, it is slower than Bochs'
Maybe I'm not configuring something?
Thanks!
Last edited by shacknetisp on Mon Aug 20, 2012 9:01 am, edited 2 times in total.
Re: Bochs RTC bug, Qemu PIT bug!
Don't shout "bug" unless you've legitimately found one and can reproduce it.
You'll make a lot of people angry.
You'll make a lot of people angry.
-
- Member
- Posts: 29
- Joined: Wed Jan 25, 2012 2:37 pm
Re: Bochs RTC bug, Qemu PIT bug!
Sorry!
I thought it must be a bug since I used code that works on real hardware...
I thought it must be a bug since I used code that works on real hardware...
-
- Member
- Posts: 29
- Joined: Wed Jan 25, 2012 2:37 pm
Re: Bochs RTC , Qemu PIT Problems
OK, I've got a work-around, but I still don't know WHY it is happening.
Re: Bochs RTC , Qemu PIT Problems
What do you mean by 'than it really is' ?
Bochs is more a simulator, than emulator: i mean it's more aimed to accuracy of CPU behavior than to real-time work. Unless you configure it to do some syncronization, it won't try to sync with host clock (and in most cases it's a rather bad idea to add this syncronization overhead). Although, the ratio between emulated clock and emulation cycles is kept accurate. It's better for you to read more about it's configuration.
Then, QEMU is more intended for fast and dirty work. It's emulation cycles are not predictable periods of time but guest OS clock is almost real-time (in terms of host clock).
Bochs is more a simulator, than emulator: i mean it's more aimed to accuracy of CPU behavior than to real-time work. Unless you configure it to do some syncronization, it won't try to sync with host clock (and in most cases it's a rather bad idea to add this syncronization overhead). Although, the ratio between emulated clock and emulation cycles is kept accurate. It's better for you to read more about it's configuration.
Then, QEMU is more intended for fast and dirty work. It's emulation cycles are not predictable periods of time but guest OS clock is almost real-time (in terms of host clock).
-
- Member
- Posts: 29
- Joined: Wed Jan 25, 2012 2:37 pm
Re: Bochs RTC , Qemu PIT Problems
So that's why it doesn't work on bochs...
But I've just been testing on a Thinkpad T60, and it acted like bochs!
(I had been running on a dell Inspiron 1501).
But I've just been testing on a Thinkpad T60, and it acted like bochs!
(I had been running on a dell Inspiron 1501).
Re: Bochs RTC , Qemu PIT Problems
I still don't catch what are you comparing guest clock (and which guest clock: TSC, RTC, HPET) with (wall clock, TSC?).
Please, give more details about your experiments.
Please, give more details about your experiments.
-
- Member
- Posts: 29
- Joined: Wed Jan 25, 2012 2:37 pm
Re: Bochs RTC , Qemu PIT Problems
Well, I've set both Bochs' RTC and the Dell's RTC to my local time.
Reading from the RTC once every second, it increments the second by 4 or 5 times for every second on the wall clock.
And for Qemu, it's PIT frequency is less than bochs'.
I set a timer to run in 10 PIT ticks:
Bochs: runs in (about) 1 second.
Qemu: runs in (about) 3 seconds.
Reading from the RTC once every second, it increments the second by 4 or 5 times for every second on the wall clock.
And for Qemu, it's PIT frequency is less than bochs'.
I set a timer to run in 10 PIT ticks:
Bochs: runs in (about) 1 second.
Qemu: runs in (about) 3 seconds.
Re: Bochs RTC , Qemu PIT Problems
The whole idea of using PIT to calibrate RTC is questionable.
PIT subject to many factor, including hardware delays, bus delay, interrupt latency, and many things.
When you set it to 18.2Hz for example, you may not get 18.2 tick per second, even on real hardware - if it look like it happen, it's pure luck.
Then, on top of that is the emulator overhead - most emulator do not provide accurate PIT (in term of real world wall clock) for various reasons.
As a side note, RTC in most computer is inaccurate compare to real world clock.
PIT subject to many factor, including hardware delays, bus delay, interrupt latency, and many things.
When you set it to 18.2Hz for example, you may not get 18.2 tick per second, even on real hardware - if it look like it happen, it's pure luck.
Then, on top of that is the emulator overhead - most emulator do not provide accurate PIT (in term of real world wall clock) for various reasons.
As a side note, RTC in most computer is inaccurate compare to real world clock.
-
- Member
- Posts: 29
- Joined: Wed Jan 25, 2012 2:37 pm
Re: Bochs RTC , Qemu PIT Problems
Thanks!
I guess I'll read some more on the RTC and PIT and see if I missed anything.
(I'll probably feel stupid )
I guess I'll read some more on the RTC and PIT and see if I missed anything.
(I'll probably feel stupid )