Space location locks

A space location lock puts a logical lock on any single byte of storage. The lock does not change the storage or effect your application's access to the storage. The lock is a piece of information recorded by the system.

Space location locks provide cooperative locking similar to that provided by mutual exclusion (mutex). However, space location locks differ from mutex in several respects:

  • You can use the space location lock directly on the data it is protecting. The space location lock does not require your application to create and maintain an additional object. Correct results in your application still depend on the fact that all threads that are accessing the data use the space location lock.
  • Space location locks allow an application to coordinate the use of different locking request types. For example, more than one thread can use space location locks to acquire a shared lock on the same data.
  • Due to the extra lock types that are provided by space location locks, the concept of an owner for space location locks is slightly different from that for mutexes. There can be multiple owners of a shared lock if each owner has successfully acquired the shared lock. For a thread to get an exclusive lock, all of the shared locks must be unlocked.
  • Space location locks have different performance implications to your application from those to mutexes. A space location lock requires about 500 reduced instruction set computer (RISC) instructions to lock in a path without contention between other threads. A mutex requires about 50 RISC instructions in the same path. However, a space location lock does not require any instructions for creation or deletion, whereas a mutex requires approximately 1000 RISC instructions for creation or deletion.
Note: Java™ does not have the ability to directly use space location locks. Space location locks require the use of pointers.