Intel® Advisor User Guide

ID 766448
Date 10/31/2024
Public
Document Table of Contents

Explicit Locking

Use ANNOTATE_LOCK_ACQUIRE and ANNOTATE_LOCK_RELEASE to specify explicit locking. These annotations are simple executable statements you can put wherever is most convenient. For example:

 if (synchronization_needed) ANNOTATE_LOCK_ACQUIRE(0);
 x = f(x, a);
 if (synchronization_needed) ANNOTATE_LOCK_RELEASE(0);

You must make sure you match the lock acquires and releases, and both occur in the same task. Your program will get synchronization errors if a task releases a lock that it does not own, or acquires a lock and fails to release it. You can acquire a lock in one function and release it in a different function, but it is a poor practice.