Intel® Advisor User Guide

ID 766448
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Assign Locks to Transactions

A transaction updates a set of shared memory locations and is controlled by a lock. In general, you need to be sure that if two transactions both access the same memory location, they will not run simultaneously. What is the best way to associate locks with transactions to accomplish that? Consider:

// transaction 1
if (a > b) { a -= b; b = b / 2; }
...
// transaction 2
if (c > d) { c -= d; d = d / 2; }
...
// transaction 3
if (a > c) { a -= c; c = c / 2; }
...
// transaction 4
temp = x;
x = y;
y = temp;

You must ensure that if two transactions can access the same memory location, t