More OS

Don’t you love that sense of satisfaction you get after you fix a rather annoying bug?

8 finished the VM rewrite for our kernel (and it looks *much* nicer now, and the PM can also magically keep track of free physical pages without needing an internal data structure [and hence, won’t use more memory if we ever happen to get more than 256MB of ram]) and we had a remarkably easy time integrating it into our main branch (although I’m still of the opinion that Subversion merging is horrific and painful).

Then the fun started. Things started out ok and init and idle started and the shell started and readline worked.
Then, when we tried to execute a task from the shell, things exploded.
After about an hour, I tracked down the problem to fork’s page-directory-and-table copying function… odd though, since that hadn’t changed since before the VM rewrite, and it was working fine before.
After poking at it some more, I determined that, for some unknown reason, one of the page tables in the newly-forked task contained garbage data. Garbage data that happened to look a lot like a kernel stack. Hmmm…
A bunch of breakpoints and plenty of x%cr3 4096 and psym "pcb->esp0" later, I discovered that, somehow, the same physical page was being mapped as both a kernel stack page and as a page table page. Very odd.
Poked at it for another couple hours until I managed to isolate the problem to one function… a function that destroys the current mappings in the page directory/tables to prepare a task for exec. Turns out it was a mistake with freeing pages… for some reason, the code was freeing a page *after* the desired page (PTR_ADD(page_loc, PAGE_SIZE)). Oops. Fixing that fixed the immediate bug but tripped an assertion.
That one turned out to be simpler… the wrong virtual address was being passed into the freeing function (*entry instead of entry). Whee.

So yeah, it appears that we are back in the same state that we were yesterday as far as runnability and such goes, except we have a shiny new VM that appears to be much happier (and much cleaner) than before.

I should probably go sleep, as it is 7:30… but it might make more sense to just stay up until class and then sleep afterward. Meh.

All we have left to do is finish vanish and write wait and we will be kernel code-complete (at least, theoretically… we’ll probably end up doing more rewrites and such). Awesomeness.

There has been much ITG lately. I need to get back into 11s… maybe I’ll manage to pass a 12 before I leave CMU. Wheee.
110107itg.jpg
110107itg2.jpg
110107itg3.jpg

One thought on “More OS

Leave a Reply

Your email address will not be published. Required fields are marked *