The fundamental operation in the client server model

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: les are declared with the static attribute so that they are not visible to other object modules. Cond is a condition variable and mutex is its associated mutex variable. Nthreads records the number of threads involved in the barrier, and barriercnt keeps track of the number of threads that have called the barrier function. The barrier init function in lines 9–14 is called once by the main thread, before it creates any other threads. The mutex that surrounds the body of the barrier function guarantees that it is executed indivisibly and in some total order by each thread. Thus, once the current thread has acquired the mutex in line 18, there are only two possibilities. 1. If the current thread is the last to enter the barrier, then it clears the barrier count for the next time (line 20), and wakes up all of the other threads (line 21). We know that all of the other threads are asleep, waiting on a signal, because the current thread is the last to enter the barrier. 2. If the current thread is no...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online