CST 334 - Week 6
This week focused on two main topics. Compared to previous weeks, the workload was lighter, which made it easier to focus and understand the material without feeling overwhelmed or frustrated. One of the key topics was semaphores, which are synchronization tools used to manage access to shared resources in multi-threaded environments. They help prevent race conditions, which occur when multiple threads try to modify data at the same time. As I understand it, semaphores are similar to locks, but they include a counter that keeps track of how many threads can access a resource. When the counter reaches zero, other threads must wait until a resource becomes available again.
The module also introduced two well-known problems that can be solved using semaphores. The first is the producer/consumer problem, where the producer must wait if the buffer is full, and the consumer must wait if the buffer is empty. This ensures that the producer does not overwrite data and the consumer does not read empty data. The second is the dining philosophers problem, where five philosophers sit around a table with one fork between each of them. In order to eat, each philosopher needs both forks on their left and right, which requires coordination to avoid deadlocks and starvation.
Another important part of this week’s content was about bugs that occur in concurrent programming. Besides deadlocks, two common types of bugs discussed were atomicity violation bugs and order violation bugs, both of which can cause unpredictable behavior in multithreaded programs.
Comments
Post a Comment