From a12fd09cfe614a9ea5095bd3cd852c79f18d5a5b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 16 Jun 2014 17:37:25 +0200 Subject: info: shared locks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- info/cmdipc.texinfo | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'info/cmdipc.texinfo') diff --git a/info/cmdipc.texinfo b/info/cmdipc.texinfo index 27a9eea..675c845 100644 --- a/info/cmdipc.texinfo +++ b/info/cmdipc.texinfo @@ -405,7 +405,7 @@ it with @option{leave}. @node Conditions @chapter Conditions -A condition is a mutex support for +A condition is a mutex with support for signalling. They are implemented using three semaphores. Just like with mutexe, you enter and leave guarded states with @@ -458,6 +458,55 @@ waiting peers, and otherwise @option{wait}. @node Shared Locks @chapter Shared Locks +A shared lock is a mutex support for +two types of locks: shared and exclusive. +They are implemented using three semaphores. +Mutexe are can be reduced from shared lock +by only using exclusive locking. Exclusive +locking allows only on program to enter +a guarded state. Shared locks introduce +shared locking works the same why but any +number of programs can be in this state +concurrently. The purpose of the shared +locking is to block exclusive locking. +If you for example are reading and writing +to a file or shared memory, you would +apply an exclusive lock if you want to +be able to modify the content of the +memory and a shared lock if you only +which to be able to read it. This +guarantees both that two processes will +edit the memory at the same time and +cause corruption, and that not process +will modify the memory while another +process is reading it, while allowing +multiple processes to read the memory +at the same time.. + +The key for a ``System V'' shared lock is +a integer-trio delimited by full stops. +The key for a ``POSIX'' shared lock is a +juxtaposition of three an ASCII strings: +no NUL or slash, between 1 character and +254 characters long, and prefixed with a +slash. + +There are four verbs for shared locks: + +@table @option +@item shared lock +Apply shared locking. + +@item exclusive lock +Apply exclusive locking. + +@item shared unlock +Release shared locking. + +@item exclusive unlock +Release exclusive locking. +@end table + @node Rendezvous -- cgit v1.2.3-70-g09d2