11.1 | Modify the example shown in Figure 11.4 to pass the structure between the threads properly. |
11.2 | In the example shown in Figure 11.13, what additional synchronization (if any) is necessary to allow the master thread to change the thread ID associated with a pending job? How would this affect the job_remove function? |
11.3 | Apply the techniques shown in Figure 11.14 to the worker thread example (Figure 11.1 and Figure 11.13) to implement the worker thread function. Don't forget to update the queue_init function to initialize the condition variable and change the the job_insert and job_append functions to signal the worker threads. What difficulties arise? |
11.4 | Which sequence of steps is correct?
Lock a mutex (pthread_mutex_lock). Change the condition protected by the mutex. Signal threads waiting on the condition (pthread_cond_broadcast). Unlock the mutex (pthread_mutex_unlock).
or
Lock a mutex (pthread_mutex_lock). Change the condition protected by the mutex. Unlock the mutex (pthread_mutex_unlock). Signal threads waiting on the condition (pthread_cond_broadcast).
|