One of the things I’m trying to understand better is multi-threading. This is one of those concepts where you can go as deep down the rabbit hole as you have an appetite to go down.
I have always felt that my multi-threading knowledge is “ok” for my daily needs:
I understand the normal synchronization problems with multi-threading (deadlocks; race conditions). I have an understanding of the mechanics of locks and mutexes. I have some appreciation of Windows threads – syntax, how they are created/executed with the main program I work on, how to debug them etc.
However, those things have left me uneasy that I don’t really know what is going on.
For some time, I have therefore wanted to go back to basics and build up a better understanding of multi-threading from the bottom up. My current study plan looks as follows:
Better understand synchronization concepts and classic synchronization problems in the abstract
So you know about locks & mutexes… What about semaphores and condition variables? How do atomics fit into this? What about lock-free programming? So you know about deadlocks and race conditions… What about starvation? How do you solve typical synchronization problems? (E.g. dining philosophers; readers-writers problem)
At the moment, my plan is to devour Downey’s Little Book of Semaphores for this step: take a whole lot of notes, solve the exercises in the book and then google all of the concepts I come across I am not familiar with.
Understand language specific threading concepts and implementations
After understanding threading concepts in the abstract, it’s important to actually get round to do some implementing (think: “learning by coding” or some similar non-sense). To do that, I first need to understand what concepts languages offer. For now, I’m planning to start with the language I am most comfortable in (C++). Here, the standard book on the topic (incorporating C++ 11 threading details) seems to be Williams’ C++ Concurrency in Action. For C#, I was planning on looking through Albahari’s free ebook on threading.
(While the C++ book comes with lots of positive reviews, I haven’t really found anything on this. So this is taking a little bit of a chance.)
(I imagine there will be a fair number of differences here depending on what execution environment we are talking about…)
Implement the problems described in Downey’s book
After that, it’ll be time to actually get my teeth into implementing the problems I have looked and solved at in the abstract in code.
Given that I am also planning on spending a fair amount of time on software processes, TDD and such Agile rubbish, I think getting through this list may well take till the end of January or so. I’ll add some posts on how I am getting on with this.