Lock (computer Science) - Language Support

Language Support

See also: Barrier (computer science)

Language support for locking depends on the language used:

  • There is no API to handle mutexes in the ISO/IEC standard for C. The current ISO C++ standard, C++11, supports threading facilities. The OpenMP standard is supported by some compilers, and this provides critical sections to be specified using pragmas. The POSIX pthread API provides lock support. Visual C++ allows adding the synchronize attribute in the code to mark methods that must be synchronized, but this is specific to "COM objects" in the Windows architecture and Visual C++ compiler. C and C++ can easily access any native operating system locking features.
  • Java provides the keyword synchronized to put locks on blocks of code, methods or objects and libraries featuring concurrency-safe data structures.
  • In the C# programming language, the lock keyword can be used to ensure that a thread has exclusive access to a certain resource.
  • VB.NET provides a SyncLock keyword for the same purpose of C#'s lock keyword.
  • Python does not provide a lock keyword, but it is possible to use a lower level mutex mechanism to acquire or release a lock.
  • Ruby also doesn't provide a keyword for synchronization, but it is possible to use an explicit low level mutex object.
  • In x86 Assembly, the LOCK prefix prevents another processor from doing anything in the middle of certain operations: it guarantees atomicity.
  • Objective-C provides the keyword "@synchronized" to put locks on blocks of code and also provides the classes NSLock, NSRecursiveLock, and NSConditionLock along with the NSLocking protocol for locking as well.
  • Ada is probably worth looking at too for a comprehensive overview, with its protected objects and rendezvous.

Read more about this topic:  Lock (computer Science)

Famous quotes containing the words language and/or support:

    We find that the child who does not yet have language at his command, the child under two and a half, will be able to cooperate with our education if we go easy on the “blocking” techniques, the outright prohibitions, the “no’s” and go heavy on “substitution” techniques, that is, the redirection or certain impulses and the offering of substitute satisfactions.
    Selma H. Fraiberg (20th century)

    The confirmation of Clarence Thomas, one of the most conservative voices to be added to the [Supreme] Court in recent memory, carries a sobering message for the African- American community.... As he begins to make his mark upon the lives of African Americans, we must acknowledge that his successful nomination is due in no small measure to the support he received from black Americans.
    Kimberly Crenshaw (b. 1959)