CST334.6 Module Six

 

CST334.6 Module Six

What I learned this week:

This week in class we covered chapters related to Semaphores and Common Concurrency Problems that exist. Continuing on the topic of Concurrency and the use of locks and conditional variables, a semaphore is an object with an integer value that contains can be incremented using sem_wait(sem_t* s) or decremented using sem_post(sem_t* s). The routine sem_wait() determine whether or not a thread will be put to sleep/wait or acquire the lock allowing the thread to continue. The routine sem_post() releases the thread and signals to wake a waiting thread. There are several ways to utilize the semaphore structure such as generating a read/write lock which can have multiple threads reading concurrently, but also provides synchronization in order to acquire the write lock when there are no readers currently present.

In regards to Common Concurrency Problems, 2 types of general bugs exist, those that are deadlock and those that are not. For those that are considered deadlock, there needs to 4 conditions that ensure that a deadlock has occurred, those are Mutual Exclusion, Hold-and-wait, No Preemption and Circular Wait. Mutual Exclusion must exist otherwise there would be no reason a thread would be held. Hold-and-Wait will occur when a thread is left waiting to acquire a lock that never becomes available. No Preemption happens when the preemptive structure of locks acquirement and release is not held. and a Circular wait bug can occur when chains of threads hold onto resources that are being requested by the next thread.

Comments

Popular Posts