Multiprocessing
(Slight Return)
Q1: Why don't we use multiprocessing more often?
A: Because multiprocessing is difficult.
Q2: Why is multiprocessing difficult?
A: Because it is complicated.
Q3: Why is multiprocessing complicated?
A: Because it has race conditions.
Q4: Why does multiprocessing have race conditions?
A: Because Threads share memory.
Q5: Why do Threads share memory?
A: Because it is more efficient to share memory when Threads are on the same processor.
Q6: Why do we use the same processor for Threads?
A: Because processors and memory are expensive.
Q7: Why are processors and memory expensive?
A: They're not expensive anymore.
Conclusion
We need to stop sharing memory. We need to put threads on separate processors when developing software for internet, robotics, IoT, distributed processing, etc.
Aside
There is only one real race condition: simultaneous arrival of events. So-called race conditions based on memory sharing, priorities, etc. are just accidental complexities. Race conditions caused by physics were explored and handled in the 1970's by Electrical Engineers. Maybe even earlier.
We are re-discovering these real problems, when dealing with distributed systems.
Acknowledgement
5 Whys suggested by Daniel Pink in Masterclass.
[This article was originally published on my old blog.]
See Also
Email: ptcomputingsimplicity@gmail.com
References: https://guitarvydas.github.io/2024/01/06/References.html
Blog: guitarvydas.github.io
Videos: https://www.youtube.com/@programmingsimplicity2980
Discord: https://discord.gg/65YZUh6Jpq
Leanpub: [WIP] https://leanpub.com/u/paul-tarvydas
Gumroad: tarvydas.gumroad.com
Twitter: @paul_tarvydas
Substack: paultarvydas.substack.com

