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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.