Journal week 6

 One of the most interesting sections from this week was the topic of semaphores as a synchronization primitive.  Semaphores serve as way to help manage concurrency and work very similarly to locks but rather than just letting one thread access critical sections. Semaphores can allow “n” number of threads through. But by setting s semaphore to a value of 1, it can act just like a binary lock. As threads pass through a semaphore, a counter goes ups and down depending on what integer was initialized. As threads use the semaphore, the value decrements and once it reaches 0, no more threads can make use of the critical section. Once a counter reaches zero, it does the “wait()” operation. As threads finish with the critical section, it lets go of the semaphore and increments the value, allowing another thread to make use of its resources. It can serve as great synchronization tool, when two semaphores are used in tandem. 

Another synchronization primitive we learned about was condition variable.   They are used long side with locks to help them wait for a certain condition to be true.  Along with semaphores and mutexes, condition variables can help synchronize threads efficiently.

One remarkable method we saw for managing threads was the Anderson Dahlin Method. This method of synchronization does use any semaphores. Instead it relies on only locks and condition variables. The benefits of using this method include: threading code is private, easier to code,  and the code is easy to understand when try to look for bugs. 


Comments

Popular posts from this blog

Journal Entry Week 2

CST334 Operating Systems Week 1