[ovs-dev] [threads 05/11] ovs-thread: Add support for various thread-related assertions.

Ben Pfaff blp at nicira.com
Fri Jun 28 23:01:48 UTC 2013


On Fri, Jun 28, 2013 at 03:34:26PM -0700, Ethan Jackson wrote:
> Should the multithreaded bool be atomic?  I doubt it matters, but
> perhaps if pthread_create()'s implementation is odd, we could have a
> problem.
> 
> Acked-by: Ethan Jackson <ethan at nicira.com>

Thanks for the review.

I don't think it's necessary for 'multithreaded' to be atomic, because
POSIX says that pthread_create() is a memory synchronization point:

    4.11 Memory Synchronization

    Applications shall ensure that access to any memory location by
    more than one thread of control (threads or processes) is
    restricted such that no thread of control can read or modify a
    memory location while another thread of control may be modifying
    it. Such access is restricted using functions that synchronize
    thread execution and also synchronize memory with respect to other
    threads. The following functions synchronize memory with respect
    to other threads:

    fork()
    pthread_barrier_wait()
    pthread_cond_broadcast()
    pthread_cond_signal()
    pthread_cond_timedwait()
    pthread_cond_wait()
    pthread_create()
    pthread_join()
    pthread_mutex_lock()
    pthread_mutex_timedlock()
    pthread_mutex_trylock()
    pthread_mutex_unlock()
    pthread_spin_lock()
    pthread_spin_trylock()
    pthread_spin_unlock()
    pthread_rwlock_rdlock()
    pthread_rwlock_timedrdlock()
    pthread_rwlock_timedwrlock()
    pthread_rwlock_tryrdlock()
    pthread_rwlock_trywrlock()
    pthread_rwlock_unlock()
    pthread_rwlock_wrlock()
    sem_post()
    sem_timedwait()
    sem_trywait()
    sem_wait()
    semctl()
    semop()
    wait()
    waitpid()



More information about the dev mailing list