Add Book to My BookshelfPurchase This Book Online

Chapter 5 - Pthreads and UNIX

Pthreads Programming
Bradford Nichols, Dick Buttlar and Jacqueline Proulx Farrell
 Copyright © 1996 O'Reilly & Associates, Inc.

Multiprocessor Memory Synchronization
The Pthreads standard requires library implementors to synchronize memory writes (with respect to reads and other writes) for a subset of Pthreads and POSIX.1 functions. For example, if a thread calls pthread_mutex_lock, the function not only protects access to the shared data but also ensures that prior modifications to that data are committed to memory at the point of the call. The way in which this is done is implementation-specific, but typically involves some memory-barrier machine instruction that synchronizes cache and memory contents across the CPUs in a multiprocessing system. The end result is that any thread's view of memory is the same as that of any other thread in the same process, regardless of which CPUs the threads are running on. 
The functions that must synchronize memory operations include: 
pthread_cond_broadcast
pthread_mutex_unlock
pthread_cond_signal
sem_post
pthread_cond_timedwait
sem_trywait
pthread_cond_wait
sem_wait
pthread_create
fork
pthread_join
wait
pthread_mutex_trylock
waitpid
pthread_mutex_lock

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback