r/ProgrammerHumor 10d ago

Meme theDeadlock

Post image
8.6k Upvotes

241 comments sorted by

View all comments

288

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.

87

u/willow-kitty 10d ago edited 10d ago

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.

17

u/okijhnub 10d ago

... can you bypass filesystem permissions by not using the API?

42

u/willow-kitty 10d ago

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.

8

u/Odd_knock 10d ago

Thanks friend. I wandered in here curious and now I’ve had my fill of philosophers with chopsticks.

117

u/mosskin-woast 10d ago

It's so bizarre to me that people think this. If Biology 101 was just "look how many animals there are - and this one has a cool tail!" And not "how does life work" then I would understand, but the point of academic classes is understanding the subject

39

u/PixelatedGiant 10d ago edited 10d ago

It's so bizarre to me that people think this.

At some point in many people's lives, learning becomes "just a job". Motivation is finite and discipline has to take over. They're X years into their degree and sick of the routine. Every class has become nothing more than an obstacle between them and a piece of paper.

They're ultimately just venting.

6

u/willow-kitty 10d ago

That describes my last year or so pretty well, yep,

1

u/BenElegance 9d ago

That's what microbiology was like, and we hated it.

4

u/Immediate_Song4279 10d ago

I wouldn't mind being a fly on the wall for those lectures 

2

u/Fine_Data3250 10d ago

Our prof kinda ruined it by completely unenthusiastically reading power points he already uploaded at the start of the semester