Temporary memory management

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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Temporary memory management

Post 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
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.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: Temporary memory management

Post 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
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: Temporary memory management

Post 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)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Temporary memory management

Post by Combuster »

There is a reason new versions of bochs get out. :roll:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: Temporary memory management

Post 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
Post Reply