HNHacker News
TopNewBestAskShowJobs

notorious_pgb

175 karma · joined December 23, 2024

submissionscomments
notorious_pgb··on A toy RTOS inside Super Mario Bros. using emulator save states
I see what you're getting at -- though then it raises the question: what would it mean for those processes to have multiple threads within them?

The way I've been looking at it, if I want to take this further, processes would maybe be _NES ROMs_, and each process can have multiple threads. Swapping between processes would inherently be more expensive than between threads within a process, which I think would be a really instructive aspect. Also, the whole idea of "sharing memory" between entirely different games is obviously ridiculous, which could be yet another teaching tool.

Then if we want to expand it even further, maybe multicore support would look like multiple emulator instances, connected via sockets to support cross-core IPC. You'd probably want to institute an "all the threads of a process have to be on the same core" rule (so they can locally share primitives in the same Lua script), which would be a great way to demonstrate the principle of building systems which adapt to their realistic constraints, as opposed to building systems which exactly model a textbook.

I've gotten ahead of myself, though.

notorious_pgb··on A toy RTOS inside Super Mario Bros. using emulator save states
Interesting; which emulator(s) was this for? I have to imagine this strategy is mostly effective below a certain total complexity level -- however you want to define that -- and the more modern you get, the more you're lucky to even render a frame at all.
notorious_pgb··on A toy RTOS inside Super Mario Bros. using emulator save states
This is one of the core weaknesses of the analogy that I'm trying to figure out how to resolve: there's no shared memory, unlike actual threads.

I think the solution requires that the game code is what's executing threading syscalls, not the Lua around the game code.

It'd definitely be a super sick evolution to add true shared in-game memory.

notorious_pgb··on A toy RTOS inside Super Mario Bros. using emulator save states
It'd be really interesting to push this to that level -- the big challenge likely being that DooM's state (including video memory) is certainly much larger and expensive to swap than an NES save state.

One would have to get really clever...

notorious_pgb··on A toy RTOS inside Super Mario Bros. using emulator save states
You're goddamn right it's pushing it.

I struggled with how to convey this; the ultimate goal is to viscerally demonstrate what a thread IS, so I'm comfortable with it being... something strange... but I do want it to resemble actual concurrent systems to a useful degree.

Like, the thread scheduler code is userland code -- similar to, say, FreeRTOS -- but the "threads" themselves aren't exactly threads in an exact sense, since their context packages are entire save states for a console, not just its processor.

Also, the game code (the true userland?) has no ability to access the threading API whatsoever, which really harms the analogy.

So I went with RTOS because it's a preemptive scheduler with synchronous reschedule-on-block; where the scheduler is implemented in the same codebase as the code using it. But to be honest, nothing I know of fits.

notorious_pgb··on A toy RTOS inside Super Mario Bros. using emulator save states
> Nor I, but I've learned from the metaphor, for what that's worth.

It's the sickest possible outcome for me, so: worth a lot!

notorious_pgb··on A toy RTOS inside Super Mario Bros. using emulator save states
Thank you!

I'm curious how effective you feel this specific example might've been if it were delivered during your course. I suspect I've stumbled across a really helpful teaching tool, but having not gone to university, I don't actually know how this stuff is being taught :v

notorious_pgb··on People Who Floss Are Better Than Everyone Else
Hey man, thanks for sharing this! I was pretty shocked to see traffic coming from YCombinator of all places. Really made my day.
← PreviousPage 2 of 2