I'm curious to know how one would code concurrent software on Intel x86 assembly. Both threads or coroutines with yielding are interesting.
I realize this isn't practical to do in assembly, but I'm just curious.
If you're talking about user space, the same way you do it in e.g. C. That is, you call pthread_create() (or whatever is the "create new thread" API on your OS) with appropriate arguments (including the address of the new thread's "main" function) and off you go.
If you're talking about bare-bones level without an OS to help you, then you'll allocate a block of memory (from the memory allocator you previously wrote) for the stack of your new thread, setup a periodic timer tick which runs (your previously written) scheduler code which saves register contents and switches between your thread stacks, etc.
As to how to do it with ASM instead of C? Well, except for a lot more sweat and tears, basically the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With