Hacker News new | ask | show | jobs
by ziedaniel1 3779 days ago
This is really cool! However, I was somewhat disappointed that it only models a linearizable memory (each low-level operation atomically acts on the same global state). It would be great to teach people that they can't actually think about memory this way, since various reorderings are possible. The UI design gets a lot trickier, but this could become a great way to teach people how to deal with things like atomic instructions, memory fences, and the differences between the x86 and ARM memory models.
1 comments

Thanks! We agree, memory models/instruction reordering is where it gets really fun and educational. The complexity scared us and we wanted to make the game usable as soon as we could, so we rather left it on the TODO list for now. Maybe one day in V2 :)
You could add a CPU write buffer or cache lines as an intermediate step between the code and memory, and allow the player to choose when those get flushed to memory, constrained by memory barrier operations.

This kind of problem comes up very often in the context of the Linux kernel. And the ability to deal with it is as even rarer among programmers experienced with concurrency than experience with concurrency is among programmers in general. A tutorial of this form for memory ordering issues would be invaluable.

I'd be happy to help with problems and game-element design for a memory-ordering version of this tutorial.