Read/write locks within and between processes. Can you help?

I have an application that is multithreaded and concurrent. Multiple instances of the application must run at the same time.

Each thread in each process accesses shared resources. For this purpose I've employed Butenhof's read-write locks. Inter-process locking is based on fcntl. For example, fcntl is used to prevent a reader from process 1 getting access to a resource that was write locked by a thread from process 2.

I am not sure that this implementation is watertight. Do you know of a "standard" implementation for this kind of mutex? Do you know of another way to implement this kind of locking?

Cheers,
Adam

You want write-execlusive locking, correct?
Otherwise read-shared locking.

I need read-write locks of the kind described by Butenhof in his "Programming with Posix Threads" book. These provide read-shared and write-exclusive access to a resource (not at the same time, naturally) within a process. I need to extend this concept to multiple processes.

An exclusive lock is supposed to stop all other access types, by definition.

You have the right model. It's usually the one implemented for shared memory access across processes - System V semaphores. Normally, there are two semphores (mutexes).

See Section 5.2 Process Semaphores in:

http://www.advancedlinuxprogramming.com/alp-folder/alp-ch05-ipc.pdf