CST 334 Week 6
WELCOME TO WEEK 6 Learning Journal This week I learned about semaphores, which are objects with an integer value that one can manipulate with the functions `sem_wait()` and `sem_post()`. It is also important to know that the initial value of the semaphore determines the way it will behave. To initialize a semaphore, one must use `sem_init()` which has three parameters, with the third one being the initial value. Depending on that value, the semaphore will behave differently. For example, if its value is 1, it behaves like a lock. However, if you want the semaphore to act like a condition variable, the initial value should be 0. This can be used, for instance, when you want semaphores for ordering. An example provided in the text is if a thread wishes to wait for a list to become non-empty so it can delete an element from it. This is often where a thread waits while another signals that it is done with what it was doing. We also learned about concurrency problems that can either be d