A toy RTOS inside Super Mario Bros. using emulator save states

This started as a throwaway metaphor in a blog post, but is now fully runnable: a toy RTOS with preemptive multitasking inside of Super Mario Bros. on the NES.

Essentially, this is:

- A rudimentary preemptive RTOS

- Using an unmodified NES emulator (FCEUX) as the CPU

    - "Unmodified" depending on how you define terms
- With emulator save states as the thread contexts

- With support for (very basic) mutexes, interrupt masking, and condition variables

- Demonstrated using Super Mario Bros. 1-1 with sections of the map dedicated to various synchronization primitives

There are many simplifications and shortcuts taken (doesn't even have task priorities), and it doesn't map 1:1 to true multithreading (e.g., emulator save states represent the state of the entire machine including RAM, whereas thread contexts represent a much more minimal slice), but I think it's A) pretty interesting and B) a unique visceral explanation of threads.


Comments URL: https://news.ycombinator.com/item?id=44120241

Points: 31

# Comments: 10

https://prettygoodblog.com/p/what-threads-are-part-2

Creată 2d | 28 mai 2025, 21:30:06


Autentifică-te pentru a adăuga comentarii

Alte posturi din acest grup

Show HN: MCP Defender – OSS AI Firewall for Protecting MCP in Cursor/Claude etc.

Hi HN,

MCP Defender is an open source desktop app that automatically proxies your MCP traffic in AI apps like Cursor, Claude, Windsurf and VSCode. It then scans all requests and responses betwee

31 mai 2025, 05:10:06 | Hacker news
Show HN: Leap – Full-stack AI developer agent that deploys to AWS

We just launched Leap, an AI developer agent that helps you build and deploy apps with real backends to your own AWS or GCP cloud.

We built it because every AI app builder we tried fell short. T

31 mai 2025, 05:10:05 | Hacker news