Comment by kaoD

7 hours ago

You can implement an executor with threading to achieve parallelism, but it's not a fundamental characteristic of Future executors.

To reiterate: an executor is just something that runs Futures to completion, and Futures are just things that you can poll for a value.

See sibling comments for additional details.

I’m aware; you’re not adding new information. I think you’re handwaving the difficulty of implementing work stealing in the kernel (interrupts and whatnot) + the mechanics of suspending/resuming the calling thread which isn’t as simple within the kernel as it is in userspace. eg you have to save all the register state at a minimum but it has to be integrated into the scheduler because the suspension has to pick a next task to execute and resume the register state for. On top of that you’ve got the added difficulty of doing this with work stealing (if you want good performance) and coordinating other CPUs/migrating threads between CPUs. Now you can use non interruptible sections but you really want to minimize those if you care about performance if I recall correctly.

Anyway - as I said. Implementing even a basic executor within the kernel (at least for something more involved than a single CPU machine) is more involved, especially if you care about getting good performance (and threading 100% comes up here as an OS concept so claiming it doesn’t belies a certain amount of unawareness of how kernels work internally and how they handle syscalls).

  • No. I am adding new information but I think you are stuck on your initial idea.

    There's no work stealing. Async-await is cooperative multitasking. There is no suspending or resuming a calling thread. There is no saving register state. There is not even a thread.

    I will re-reiterate: async-await is just a state machine and Futures are just async values you can poll.

    I'm sure moss has an actual preemptive scheduler for processes, but it's completely unrelated to its internal usage of async-await.

    See embassy in sibling comments.