by shortrounddev2 · 3y ago · 0 comments
Classes usually only required a single java file to turn in your work, which was then compiled and run automatically with the results being verified by another program, so as long as your individual java file output the same results as what was expected, it didn't matter what build system (if any) you used.
The only other class that didn't use java was systems programming, where we did C. I had been doing C since I was 12 at that point, and since I was already using ubuntu server via ssh, it wasn't a difficult class at all for me.
For my OS final, we had to write an operating system simulator (a program which simulated the kind of events that would occur in an OS: new processes, processes being deleted, memory paging, single process multi-tasking with pre-emption). I didn't actually read the instructions and ended up writing a kind of hypervisor(?) which ran programs in an 8080 emulator with some of my own custom instructions for memory banking and forking to meet the requirements of the class (your program had to be able to do memory paging up to something like 512mb of RAM).
You had to have some kind of user interface, so I wrote it as a web server in C with a custom HTTP server implementation. The program returned an HTML page which looked like a desktop. You could spawn terminal windows and run specific programs. I wrote a few long-running programs which printed out numbers to demonstrate memory paging and process pre-emption. There was a special instruction I made to fork the program so you could clone a process from another process, and I used one of the unused flag register bits to signify which fork the program was.
The professor was impressed by the implementation (and I implemented all the algorithms required to get 10 points extra credit), but because I didn't actually write an OS simulator (closer to an actual OS, but not quite there), he gave me 100%, but no extra credit. I was happy with that, because I'm not a grade chaser.
Unfortunately, I failed the class because I couldn't answer trivia on the exam like "What does GRUB stand for" because I spent the whole semester working on the hypervisor and not actually going to any of the lectures. I just read the textbook and coded in C at the library.
Here's the very rough code, with a slightly buggy 8080 emulator implementation:
BTW have a look at this blog post: <https://eli.thegreenplace.net/2023/faas-in-go-with-wasm-wasi...>. It uses a lot of off-the-shelf components like a WASM runtime instead of a custom 8080 emulator, and net/http rather than rolling your own HTTP server - but it's fascinating, how close your crazy project ended up from actually viable real-world use cases.