Page 2 of 2

Re: Temporary memory management

Posted: Tue Jun 24, 2008 7:37 am
by Brendan
Hi,
suthers wrote:It assembles fine, but it causes an error in bochs 2.0.2, but not in 2.3.6....
Weird.
I looked at bochs 2.0.2 debug output to find the error... turns out bochs 2.0.2 generates a system timer interrupt before my IDT is setup, where as 2.3.6 doesn't...
Weird, but I can live with that (for some reason I prefer 2.0.2 because I started with it, but I'm trying to shift completely to 2.3.6... )
That sounds like a serious bug to me - if the timer IRQ occurs before you're ready the OS crashes.

Bochs 2.0.2 probably has different timing to Bochs 2.3.6 so it only crashes on Bochs 2.0.2; but a real 80486, a real Pentium, a real Opteron, a real Celeron all have different timing too - I wonder how many real computers your OS will (or won't) crash on? Heck - I wonder what would happen if you played with your "bochsrc.txt" files (changing your "ips=10000000" to a different value could make your OS crash or work under either version of Bochs).

Worse, Bochs is fairly deterministic (i.e. same amount of time between "power-on" and the PIT's IRQ each time you run it) but real hardware may not be deterministic. For example, if there's a boot manager or something and the user needs to press a key to continue, then you get a different amount of time between "power-on" and the PIT's IRQ every time you boot - the OS would crash randomly (depending on exactly how quick the user presses a key). You could also get a situation where the OS works if you boot from floppy but crashes if you boot from CD-ROM on the exact same computer. Timing bugs are nice like that; which is why they're so annoying to find and fix, and why you should fix it immediately (while you can).

Note: for debugging, if you can get it to crash then you can find the problem (Yay!), but if you can't get it to crash then you can't find the problem and you're screwed (Doh!)... ;)
suthers wrote:P.S. Brendan, If you don't use a linker script what do you use?
I use NASM to generate flat binaries - no linker (and no linker script).


Cheers,

Brendan

Re: Temporary memory management

Posted: Tue Jun 24, 2008 7:49 am
by suthers
The main problem would be how to fix it, I'd have to diminish the amount of instructions executed before they occur...
How exactly would I do that...?
Also another weird bug, One single timer IRQ is generated after which, there are no more, I hadn't noticed this before, but now that I have the PIT setup, I can see that only one occurs after which nothing....
Jules

Re: Temporary memory management

Posted: Tue Jun 24, 2008 8:15 am
by suthers
Simple fix, I added a cli right at the beginning of my kernel and then and sti once my IDT is setup...
I'll work on the whole system timer interrupt problem now...
Thanks,

Jules

P.S. wow entire kernel written in asm, that must be time consuming... (though when debugging it can often be an advantage...., to the point where I have considered it my self)

Re: Temporary memory management

Posted: Tue Jun 24, 2008 9:53 am
by Combuster
There is a reason new versions of bochs get out. :roll:

Re: Temporary memory management

Posted: Tue Jun 24, 2008 9:59 am
by suthers
Combuster wrote:There is a reason new versions of bochs get out. :roll:
I only use 2.0.2, because it was the first one I used...
But it wasn't a bug anyway, all it was was that the timer first fires earlier on 2.0.2 than on 2.3.6...
Jules