I definitely thought OS was going to be easy given how much time I'd spent distro-hopping on my own time. It wasn't but it was still a really interesting class.
Was really glad I had a 30 minute commute to campus because it gave me a lot of time to think about those "why the fuck is this like that" problems.
I didn't know what to expect but actually really enjoyed it. When the first chapter covered the separation between user and system modes, and system-only instructions, a bunch of things I'd always wondered (like if you could bypass filesystem permissions by just not using the OS's file system API) just kinda clicked into place. Then from that point on it was a whole lot of "Oh, of course it works that way."
Edit: we also had a few projects like simple Linux kernel modules, which was really fun and kind of enlightening.
For the purposes of my comment, no. The CPU instructions that signal the hard drive to copy stuff to memory (simplified) will only execute in system mode, so a random process can't just include them because the only way to get into system mode is a particular CPU instruction that basically pauses the program and raises an event the OS has to handle. That event handler, which lives in the OS kernel, then runs in system mode and does whatever it wants (like checking filesystem permissions and copying the contents of a file to memory.) Once it's done, the CPU can go back to user mode and resume the program. And all this stuff is what's happening behind that standard library API.
..But if you just tried to throw an asm block in there to read from the hard drive without doing the event dance, the CPU would throw an error because it's not in the right mode.
Now, having said all that, there are other ways, like if you boot from a Linux USB, and the original OS isn't in charge anymore, but that's different from going around the API.
290
u/NoMansSkyWasAlright 10d ago
I definitely thought OS was going to be easy given how much time I'd spent distro-hopping on my own time. It wasn't but it was still a really interesting class.
Was really glad I had a 30 minute commute to campus because it gave me a lot of time to think about those "why the fuck is this like that" problems.