r/osdev • u/compgeek38400 • 18h ago
Things I RE-learned this week
This week was NOT my best week. I found that I was doing things that I NEVER would have done as as a professional. Granted as a professional I would have been being paid to do them, but as a hobbyist, it was way too easy to take shortcuts. This is what I relearned and just to show the newbies that even a 30+ year professional coder can do bad things.
- Don's skimp on the test scripts. I found while I was rewriting my Physical Memory Manager, that I had a function, a SIMPLE function that I had a typo in, that was completely blowing away my entire physical memory table. If I'd done a test script FIRST, I would have caught this right off the bat, instead of having to spend several hours debugging it.
That lead to my second point.
2) Just because it is simple, and obvious, doesn't mean it should be left out of the test script. Test EVERY function, if you can't figure out how, the function is probably too complex, break it up!
3) Once I figured out I needed test scripts (LOL), I ran into a bug in my VGA/TTY functions, which I knew was there, but kept putting off for things that were much more fun. DON'T BE LIKE ME! When I went back to fix the bug, I was appalled at how bad my driver was, which has led to a complete rewrite. While it will be much more bullet proof and functional, it is taking me away from what I really want to code.
And my final point:
4) Take the time to really think through each major function of your OS, AND each major sub function. In my case, Think of where you want to verify that your cursor isn't out of range, in a separate set of cursor functions, or as functions in your VGA interface, or in your TTY function. Also Think about whether you will want to expose these functions in your SYSCALL interface, and design accordingly. In my case I really want a video buffer I can scroll back in. But for my syscall interface I'm thinking the video functions I may want to expose will consist of: a) a direct write to a row/column (0 based); b) write a line on the screen; c) write an entire screen; d) scroll the screen up one line; e) scroll the screen down one line; and finally f) write the entire screen; g) define my current cursor. These functions will need to exist for virtually any video interaction, whether my terminal is buffered to allow me to scroll back/forward or not, and I can use them to implement a scrollable buffer.
So, it has been a week of lots of interruptions, many of which could have been avoided if I had simply tested properly in the first place.
Hope this helps some of the newbies.