Advanced Programming in the UNIX® Environment
ptg10805159 Section 11.6 Thread Synchronization 407 tfp = tfp->f_next; tfp->f_next = fp->f_next; } pthread_mutex_unlock ...
ptg10805159 408 Threads Chapter 11 #include "apue.h" #include <pthread.h> int main(void) { int err; struct timespec tout; ...
ptg10805159 Section 11.6 Thread Synchronization 409 Mac OS X 10.6.8 doesn’t supportpthread_mutex_timedlockyet, but FreeBSD 8.0, ...
ptg10805159 410 Threads Chapter 11 resources for the reader–writer lock, pthread_rwlock_destroy frees those resources. If we fre ...
ptg10805159 Section 11.6 Thread Synchronization 411 pthread_t j_id; /* tells which thread handles this job */ /* ... more stuff ...
ptg10805159 412 Threads Chapter 11 jp->j_prev = qp->q_tail; if (qp->q_tail != NULL) qp->q_tail->j_next = jp; else ...
ptg10805159 Section 11.6 Thread Synchronization 413 In this example, we lock the queue’s reader–writer lock in write mode whenev ...
ptg10805159 414 Threads Chapter 11 variable, but if the condition variable is allocated dynamically, we can use the pthread_cond ...
ptg10805159 Section 11.6 Thread Synchronization 415 obtain the absolute time for the timeout value, we can use the following fun ...
ptg10805159 416 Threads Chapter 11 #include <pthread.h> struct msg { struct msg *m_next; /* ... more stuff here ... */ }; ...
ptg10805159 Section 11.6 Thread Synchronization 417 11.6.7 Spin Locks Aspin lock is like a mutex, except that instead of blockin ...
ptg10805159 418 Threads Chapter 11 To lock the spin lock, we can call eitherpthread_spin_lock,which will spin until the lock is ...
ptg10805159 Section 11.6 Thread Synchronization 419 When we initialize a barrier, we use thecountargument to specify the number ...
ptg10805159 420 Threads Chapter 11 int (*)(const void *, const void *)); #endif /* *Compare two long integers (helper function f ...
ptg10805159 Section 11.6 Thread Synchronization 421 minidx = i; } } snums[sidx] = nums[idx[minidx]]; idx[minidx]++; } } int main ...
ptg10805159 422 Threads Chapter 11 This example shows the use of a barrier in a simplified situation wherethe threads perform on ...
ptg10805159 Chapter 11Exercises 423 or Lock a mutex (pthread_mutex_lock). Change the condition protected by the mutex. Unlock t ...
ptg10805159 This page intentionally left blank ...
ptg10805159 12 Thread Control 12.1 Introduction In Chapter 11, we learned the basics about threads and thread synchronization. I ...
ptg10805159 426 Thread Control Chapter 12 Name of limit Description nameargument PTHREAD_DESTRUCTOR_ITERATIONS maximum number of ...
«
18
19
20
21
22
23
24
25
26
27
»
Free download pdf