CST 334 - Operating Systems - Week 6

 


This week in CST 334, we learned about the concept of semaphores, a fundamental synchronization primitive in operating systems. Semaphores manage access to shared resources using an integer value, which can be incremented or decremented by operations like `sem_post()` and `sem_wait()`. These operations allow semaphores to control resource access, ensuring that threads wait when the resource is unavailable and proceed when it becomes available. A key form of semaphore is the binary semaphore, which functions similarly to a lock by permitting only one thread access at a time, ensuring mutual exclusion. 

In addition to basic semaphore usage, we explored various common concurrency problems that semaphores can help solve. For example, in the Producer-Consumer problem, semaphores signal the state of a buffer, preventing data corruption or loss. Similarly, the Reader-Writer problem uses semaphores to manage access, allowing multiple readers or a single writer to use the resource, but not both. This week's lessons focused on not only the functionality of semaphores in handling synchronization but also the importance of carefully implementing them to avoid common risks like deadlocks and race conditions. Lastly, for this week’s PA5 assignment, we had to implement code by first making a database thread-safe by adding locks and condition variables, and second, making a web server multi-threaded and able to use the thread-safe database. The assignment was challenging but it helped us understand more the concept of concurrency and threads.

Comments

Popular posts from this blog

CST 300 - Major ProSeminar - Week 1

CST 300 - Major ProSeminar - Week 2

CST 300 - Major ProSeminar - Week 4