|
From: Philippe W. <phi...@sk...> - 2011-12-10 09:29:08
|
> - Is there a way to use a semaphore or other synchronization primitive > in the shared memory? I don't think semaphore.h is available. Effectively, I do not think that the Valgrind core provides inter-process synchronisation mechanism. => for such missing system calls that you need, a VG_(xxxxxx) must be implemented. Note that for this, you must call the "underlying" direct syscall interface : you cannot call the "libc" layer which provides the classical user level system call. For an example, you might look at the implementation of VG_(open) in m_libcfile.c. These VG_(xxxxx) are usually trivial to implement, as soon as you know which syscall nr you need. I do not know on which underlying system calls the posix semaphores (semaphore.h) are implemented. >From what I can see, you could use __NR_futex (but this is linux only, will not work on Darwin) or the SYSV semaphores systemcalls (__NR_semget, __NR_semop, ...), corresponding to the semget, semop, ... system calls. > - I'm using shm_open() in my application, but VG_(open) in the tool - > meaning that the shared memory file needs to be specified directly > using the /dev/shm/... path. Is there a better way to do this? You are not obliged to use the /dev/shm path. For gdbserver shared memory, the shared memory file is (by default, changeable via --vgdb-prefix argument) created using VG_(open) in the TMPDIR. Philippe |