|
From: Bart V. A. <bva...@ac...> - 2012-02-15 07:22:41
|
On Wed, Feb 15, 2012 at 12:54 AM, Philippe Waroquiers <phi...@sk...> wrote: > So, we might need to have a bunch of readers/writer locking > (for some data structures) and some fine grained locking for > smaller data structures (e.g. the memcheck free list, the malloc data > structures, ...). > With the current implementation, we need 3 pipes for each readers/writer > lock (2 if we use atomic instructions) + we will need one pipe for each > "fine grained" lock. => it looks like a more lightweight locking > mechanism might be needed (futex based maybe ? but what for Darwin ? > maybe use normal pthread mutexes on Darwin ? ) It looks like the right time to me to add locking primitives in the Valgrind core (e.g. mutual exclusion + reader-writer lock). The Darwin source code is available online under a BSD license. You can have a look at it to see how locking primitives have been implemented in their C library. Note: glibc mutexes do a little more than invoking the futex syscalls directly - if I remember correctly the pthread_mutex_lock() implementation first spins for a short time in order to minimize the number of system calls invoked. Bart. |