CST 334 - Week 5
Week 5 Overview: This week in CST 334, I learned a lot about locks and concurrency. The most interesting part was understanding how different types of locks work especially spin locks vs ticket locks. At first, I thought all locks were the same, but now I see how much design actually matters. Spin locks are simple but waste CPU cycles under high contention. Ticket locks are smarter. They use a “take-a-number” approach, which makes things more fair and avoids starvation. We also learned about hardware instructions like test-and-set and compare-and-swap. These are used to build locks at a lower level. It really showed me how messy things can get when threads share data without proper coordination. Even a small race condition can lead to unpredictable bugs. We also had the midterm this week, which was honestly rough. The one-hour time limit was tight, and it felt super rushed, especially since we’ve had unlimited time on quizzes before. Some of the questions were a lot harder than expecte...