cst 334: week 6

This week in CST 334, I learned about semaphores and common issues that happen when multiple threads run at the same time. A semaphore is a tool that helps control access to shared resources. It tells threads when they can continue and when they need to wait. There are two main types of semaphores, a counting semaphore allows a certain number of threads to access something, like letting three people into a room at once, and a binary semaphore only lets one thread in at a time. This helps prevent threads from crashing into each other when trying to use the same resource. I also learned about some common problems that come up with concurrency. One big issue is a race condition. That’s when two threads try to change the same data at the same time, which can cause errors or weird behavior. Another problem is deadlock, and this happens when threads are stuck waiting for each other and nothing moves forward. There’s also starvation, which is where one thread keeps getting skipped and never gets a chance to run. These problems are tricky and can be hard to spot, but they’re important to understand. All in all, this week's learnings helped me see how important it is to manage threads accurately since it was challenging for me before. Semaphores are one way to possibly keep everything organized and in order. 

Comments