Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

In an attempt to fundamentally understand any concept, I try to understand the meaning of the words within the context it is being used. Currently, I am trying to fundamentally understand the whole acquire/release semantics since I briefly touched upon this in school.

According to this article on MSDN, an operation has Acquire Semantics if other processors will see the effect of its change before the changes of any other operation.

On the otherhand, an operation has Release Semantics if other processors will see the effect of any preceding operation before seeing the effect caused by this operation.

I get it but the question is: what do the terms acquire and release relate to any of this? If I were to explain this concept to say my daughter in grade 8, how do I translate these terms to their actual meanings?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

The reference is to some resource that fundamentally cannot be held by two agents simultaneously.

The classical example is a lock, mutex, semaphore or similar construct, and the canonical use case is making a money transfer. If you acquire an unsharable resource before subtracting and adding the amount from the two accounts, and don't release it until afterwards, and all operations on the accounts require that resource, then it's guaranteed that the amount of money in your system stays constant (as it should as per the principles of accounting). This is a good thing.

Since most solutions of the consistency problem come down to variations of such am unshareable resource, "Acquire and Release semantics" apparently are a shorthand of talking about them, without mentioning locs at all (I didn't know this before, but it sounds quite reasonable).

share|improve this answer
    
All great answers, thanks. In this case though, within the context of acquire in terms of an operation, what is the resource? When it states that Acquire Semantics means other processors will see the effect of an operation's change before the changes of any other operation, what is the resource under contention here? –  e28Makaveli Apr 20 at 23:53

From here:

The easy way to remember the difference between Acquire and Release is that Acquire is typically used when you are acquiring a resource (for example, taking a lock), whereas Release is typically used when you are releasing the resource.

share|improve this answer

They are trying to establish a correspondence between the terminology related to interlocked operations and the terminology related to acquiring/releasing a guarded resource, which is not an unreasonable thing to do, since the former are usually performed in order to accomplish the latter.

  • When performing an interlocked operation for the purpose of acquiring a resource, it does not really matter what happens before the acquisition, all that matters is that whatever operations are carried out on the resource once it has been acquired do in fact appear (from the point of view of other threads) to happen after the acquisition takes place, otherwise the resource might appear to be modified before it is locked.

  • When performing an interlocked operation for the purpose of releasing a resource, it does not really matter what happens after the release, all that matters is that the last operations carried out on the resource prior to its release do in fact appear (from the point of view of other threads) to happen before the release takes place, otherwise the resource might appear to be modified after it has been unlocked.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.