Tuesday, July 30, 2024

CST 334 - Week 6

 For this week, we learned more about concurrency, focusing mainly on semaphores and common concurrency problems. A semaphore is a synchronization primitive that can be manipulated to be used as both a lock and a condition variable. Some of the (non-deadlock) concurrency problems that were covered were atomicity violations and order violations. An atomicity bug is where a section of code is meant to run atomically but has the potential to be interrupted before completion and leave things partially executed. A simple solution to this bug is to add locks around critical sections. An order violation is when things are assumed to happen in a certain order, but the order isn't being enforced. Condition variables can be implemented to solve this problem and enforce a specific flow. Other than these bugs, we also covered deadlocks, which occurs when two threads are waiting for each other and thus, neither are productive. There are four conditions that need to be met for a deadlock to occur: (1) mutual exclusion, (2) hold-and-wait, (3) no preemption, and (4) circular wait.

No comments:

Post a Comment