In shared-memory computer systems, threads may communicate with one another using shared memory. A receiving thread may poll a message target location repeatedly to detect the delivery of a message. Such polling may cause excessive cache coherency traffic and/or congestion on various system buses and/or other interconnects. A method for inter-processor communication may reduce such bus traffic by reducing the number of reads performed and/or the number of cache coherency messages necessary to pass messages. The method may include a thread reading the value of a message target location once, and determining that this value has been modified by detecting inter-processor messages, such as cache coherence messages, indicative of such modification. In systems that support transactional memory, a thread may use transactional memory primitives to detect the cache coherence messages. This may be done by starting a transaction, reading the target memory location, and spinning until the transaction is aborted.
Legal claims defining the scope of protection, as filed with the USPTO.
1. A computer-implemented method, comprising: executing a given thread on a given processor; reading, by the given thread, as part of one transaction in a transactional memory system a value from a shared memory location, wherein the shared memory location is shared by another thread executing on a different processor, wherein the shared memory location represents a lock and the value of the shared memory location represents a value of the lock; subsequent to said reading, beginning execution of a sequence of program instructions by the given thread as part of the transaction; during execution by the given thread of the sequence of program instructions, receiving, by the given processor, an inter-processor message from the different processor indicating that a value has been written to the shared memory location, wherein the indication that the value has been written to the shared memory location indicates that the other thread has released the lock; in response to receiving the inter-processor message, aborting the transaction wherein aborting the transaction terminates the execution of the sequence of instructions; and subsequent to receiving the inter-processor message, attempting to acquire the lock by the given thread.
2. The computer-implemented method of claim 1 , wherein said sequence of program instructions comprises: a programmatic loop that defines a condition for exiting the loop that cannot be satisfied by execution of the loop, or a programmatic loop that does not define a condition for exiting the loop; and wherein said terminating comprises terminating execution of the programmatic loop in response to said abort of the transaction.
3. The computer-implemented method of claim 1 , wherein the transactional memory system executes on a plurality of processors, including the given processor and the different processor.
4. The computer-implemented method of claim 3 , the method further comprising: detecting, by the transactional memory system executing on the different processor, that the value has been written to the shared memory location; and communicating, by the transactional memory system, the indication to one or more of the plurality of processors, including the given processor, wherein the abort of the transaction is in response to said communicating.
5. The computer-implemented method of claim 4 , wherein said detecting further comprises determining that the value written to the shared memory location is different than the value read from the transactional memory location by the given thread; and wherein said communicating is performed in response to said determining.
6. The computer-implemented method of claim 1 , wherein the indication comprises a value of a hardware performance counter configured to count cache coherence messages.
7. A system, comprising: one or more processors; and a memory coupled to the one or more processors and storing program instructions executable by the one or more processors to implement: executing a given thread on a given processor of the one or more processors; reading, by the given thread as part of one transaction in a transactional memory system, a value from a shared memory location, wherein the shared memory location is shared by another thread executing on a different processor, wherein the shared memory location represents a lock and the value of the shared memory location represents a value of the lock; subsequent to said reading, beginning execution of a sequence of program instructions by the given thread as part of the transaction; during execution by the given thread of the sequence of program instructions, receiving, by the given processor, an inter-processor message from the different processor indicating that a value has been written to the shared memory location, wherein the indication that the value has been written to the shared memory location indicates that the other thread has released the lock; in response to receiving the inter-processor message, aborting the transaction, wherein aborting the transaction terminates the execution of the sequence of instructions; and subsequent to receiving the inter-processor message, attempting to acquire the lock by the given thread.
8. The system of claim 7 , wherein said sequence of program instructions comprises: a programmatic loop that defines a condition for exiting the loop that cannot be satisfied by execution of the loop, or a programmatic loop that does not define a condition for exiting the loop; and wherein said terminating comprises terminating execution of the programmatic loop in response to said abort of the transaction.
9. The system of claim 7 , wherein the one or more processors comprises the given processor and the different processor, and wherein the transactional memory system executes on a plurality of processors, including the given processor and the different processor.
10. The system of claim 9 , wherein the program instructions are further executable to implement: detecting, by the transactional memory system executing on the different processor, that the value has been written to the shared memory location; and communicating, by the transactional memory system, the indication to one or more of the plurality of processors, including the given processor, wherein the abort of the transaction is in response to said communicating.
11. The system of claim 10 , wherein as part of said detecting, the program instructions are further executable to implement determining that the value written to the shared memory location is different than the value read from the transactional memory location by the given thread; and wherein said communicating is performed in response to said determining.
12. A non-transitory, computer readable storage medium storing program instructions executable by one or more processors to implement: executing a given thread on a given processor of the one or more processors; reading, by the given thread as part of one transaction in a transactional memory system, a value from a shared memory location, wherein the shared memory location is shared by another thread executing on a different processor, wherein the shared memory location represents a lock and the value of the shared memory location represents a value of the lock; subsequent to said reading, beginning execution of a sequence of program instructions by the given thread as part of the transaction; during execution by the given thread of the sequence of program instructions, receiving, by the given processor, an inter-processor message from the different processor indicating that a value has been written to the shared memory location, wherein the indication that the value has been written to the shared memory location indicates that the other thread has released the lock; in response to receiving the inter-processor message, aborting the transaction wherein aborting the transaction terminates the execution of the sequence of instructions; and subsequent to receiving the inter-processor message, attempting to acquire the lock by the given thread.
13. The non-transitory, computer readable storage medium of claim 12 , wherein said sequence of program instructions comprises: a programmatic loop that defines a condition for exiting the loop that cannot be satisfied by execution of the loop, or a programmatic loop that does not define a condition for exiting the loop; and wherein said terminating comprises terminating execution of the programmatic loop in response to said abort of the transaction.
14. The non-transitory, computer readable storage medium of claim 12 , wherein the transactional memory system executes on a plurality of processors including the given processor and the different processor.
15. The non-transitory, computer readable storage medium of claim 14 , wherein the program instructions are further executable to implement: detecting, by the transactional memory system executing on the different processor, that the value has been written to the shared memory location; and communicating, by the transactional memory system, the indication to one or more of the plurality of processors, including the given processor, wherein the abort of the transaction is in response to said communicating.
16. The non-transitory, computer readable storage medium of claim 15 , wherein as part of said detecting, the program instructions are further executable to implement determining that the value written to the shared memory location is different than the value read from the transactional memory location by the given thread; and wherein said communicating is performed in response to said determining.
17. The non-transitory, computer readable storage medium of claim 12 , wherein the indication comprises a value of a hardware performance counter configured to count cache coherence messages.
Cooperative Patent Classification codes for this invention. Click any code to explore related patents in that topic.
April 27, 2015
September 15, 2020
Browse 5M+ US patents with plain-English claim translations and AI-generated analysis.