Quiz 4 Due 11/24/09 1. Describe two ways to detach a thread. 2. Why would creating dozens of joinable pthreads within a process be a disadvantage? 3. Thread 2 issues a pthread_cancel(3) on thread 3. Is thread 3 automatically terminated? Explain. 4. The function testandsetonce.c from our textbook is shown below. It is one way to guarantee that a mutex variable is initialized just once. #include int testandsetonce(int *ovalue) { static int done = 0; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; int error; if (error = pthread_mutex_lock(&lock)) return error; *ovalue = done; done = 1; return pthread_mutex_unlock(&lock); } a) What is the purpose of the static keyword on the variables done and lock. b) What is another way of guaranteeing that a synchronization variable is initialized only once? 5. Why are semaphores considered more flexible than mutex lock variables?