I have been watching the good old Stanford CS course Programming Paradigms. The first half of the course deals with C and serves as great material for learning C. Then the course introduced threads, and concurrent programming in C with some homebrew library. The most complicated example given is this program that simulated the icecream shop. Here are the description of the problem: This program simulates the daily activity in an ice cream store.
We are going to write a program, a bit program, lots of stuff happening here and there, ok, big program. Now, lots of threads of course, loads and loads of them, we have to synchronize, yes we do, I think so, yeah, synchronize very important stuff, good idea, but, why? Remember what we have been taught in school? That mutex thing? Mutual Exclusive? That 2 threads are trying to read and write some mutual value at the same time and create a big mess?