Login
You're viewing the front-end.social public feed.
  • Jul 10, 2026, 6:13 PM

    Across most of the emulators I've studied ensuring the timing of the emulated chips lines up correctly has consistantly required some care, but nowhere more so than for the Super Nintendo Entertainment System! So BSNES bundles a cooperative multithreading library "LibCo".

    The core logic here is CPU-specific (implemented for AArch64, AMD64, ARM, PowerPC, PowerPC64v2, SJLJ via UNIX signal handlers, & x86) writing all registers to one pointer whilst reading them from another.

    1/2?

    💬 1🔄 1⭐ 0

Replies

  • Jul 10, 2026, 6:20 PM

    Weirdly LibCo implements these in machine code rather than Assembly code, and takes care that this code can only be read/executed. Also (de)initializing threads is CPU-specific in terms of how much RAM's required.

    Also it can defer to Windows' Fibers library, or POSIX's UContext library. I'll note that ARM has a particularly easy time swapping threads, only a couple opcodes!

    Turns out that LibCo is all ports, no machine/kernel generic code!

    2/2 Fin for today!

    💬 0🔄 1⭐ 0