DEV Community

Discussion on: Is Cooperative Concurrency Here to Stay?

Collapse
 
nestedsoftware profile image
Nested Software • Edited

Thank you for your comments!

Pre-emptive multi-tasking systems require the programmer to deal with shared state very carefully,

This is a good point. With some applications - certainly most Web apps - there is no real-time communication among threads. In that case it's luckily not an issue. There may be communication mediated by something like a database that all the threads can access, but those semantics are much simpler than the programmer having to deal with shared memory manually.

I have used a co-operative model in an environment where my team have full control of the code (a microcontroller in this case)

That's a cool example. Especially if there's only one physical CPU/core, the simplicity of doing an event loop makes sense to me. I suppose in the case of multiple cores, one could implement a message passing system between threads and continue using an event model, though having to implement that from scratch sounds like it could be a lot of work. Was the microcontroller code done in C? Or would you have to drop down all the way into assembly?