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?

Collapse
 
phlash profile image
Phil Ashby

Good point on delegating thread synchronisation / communication to an existing trusted system (like a DB), although that still leaves room for pain (eventual consistency anyone?).

The MCU design was for a tiny 8-bit Freescale device on a satellite, so one core, little RAM (6k) and bare metal coding in C, with a couple of lines of ASM to issue the WAIT instruction. Also zero opportunity for code fixes once launched - we did 2 years of testing!

Thread Thread
 
nestedsoftware profile image
Nested Software • Edited

That's really cool! If you have a chance to write it up as an article at some point, I for one would love to read it!

Thread Thread
 
phlash profile image
Phil Ashby

I really should do that - although ITAR prevented us publishing the source code when we did the work (en.wikipedia.org/wiki/Internationa...) it might be ok now.. the joys of regulation!

Having done a few talks for radio hams I'll probably write that up as an article for the satellite team website (funcube.org.uk) and syndicate it here :)