I started this week on Sunday as usual with the self-quiz; starting with the self-quiz -before reading- gives me an indicator or guidance of what to expect in the reading. I found the self-quiz to be very helpful in this regard.
The topic of this week was An Introduction to Concurrency. The book was so helpful in explaining the idea with a real-life example, then discussing concurrency (multithreading) in a simple program; then it shifted towards the available POSIX APIs for concurrency.
The text explored critical sections, and mutual exclusion techniques to ensure that only one thread can access a critical section at a time. It also discussed the idea of locks, signals, and condition variables; and then how they can be used to solve the problem of mutual exclusion.
Understanding the locks was challenging, but then I thought about it as a boolean indicating if a critical section is being modified by some thread or not. It is important to place the lock in the right place of memory to be shared between all threads that need to listen to this lock.
A big surprise for me was according to (Arpaci-Dusseau, 2018), it is not a good idea to use booleans (aka, flags) to implement mutual exclusion; however, using signals is always a better idea since there is special support for signals in the POSIX API, OS, and hardware.
It is also important to remember that all variables within a thread are private and their life ends with the thread being completed. Therefore, if a thread needs to share data or data needs to live longer than the thread; these data must be placed in the heap of the process.
The discussion assignment asked about explaining the concurrency problem and suggesting solutions for it; There were quite a few good submissions out there with some diagrams that helped to explain the section or discuss whether to put the locks within the loop or outside of it.
Operating systems exist everywhere around us; since they are intermediate between humans and hardware, they are used in every aspect of our lives.
Every smart (or nearly smart) device has an operating system that is responsible for managing the hardware and providing an interface for the user to interact with the device.
This may include Computers, Desktops, Fridges, Washing Machines, Cars, Smartphones, TVs, Watches, and so on.
Linux is the most popular OS for servers and embedded devices; Windows is the most popular OS for desktops and laptops; and Android is the most popular OS for smartphones.
The existence of these OSes facilitates our daily activities a great deal; for example, Smartphones or Smart Washing Machines have hundreds of different functions but we don’t see hundreds of buttons on the devices, instead, we have a simple interface that allows us to interact with the device and perform the desired task.
If this was not the case, and a function has been changed or added; the physical design of the device would have changed to stay in sync with the new functions.
But that’s not the case, we do install/uninstall new functions on our smartphones daily, and the physical design of the device remains the same.
Arpaci-Dusseau, R. H., & Arpaci-Dusseau, A. C. (2018). Operating systems: three easy pieces (1.01 ed.). Arpaci-Dusseau Books. https://pages.cs.wisc.edu/~remzi/OSTEP/