2.1.22 Ensuring thread safety

Products: Abaqus/Standard  Abaqus/Explicit  

Reference

Overview

Utility function get_thread_id can be called from any Abaqus user subroutine. get_thread_id returns the ID that Abaqus assigns to each of its threads. These IDs are increasing integers starting from 0 (i.e., 0, 1, 2, 3, 4, etc.). The thread with ID 0 is the main thread.

In thread-parallel execution mutexes can be used to protect a common block or a common file from being updated by multiple threads at the same time. Abaqus provides 10 predefined mutexes that are referenced simply by number (1–10). MutexCreate(1) initializes mutex 1.MutexLock(1) and MutexUnlock(1), which respectively lock and unlock mutex 1. Other mutexes (up to 10) can be used in the same manner.


get_thread_id

Interface

Fortran:
                 INTEGER get_thread_id

C/C++:
         thread_id get_thread_id()

Variable returned from the utility routine

thread_id

Current thread ID, an integer.


MutexInit, MutexLock, and MutexUnlock

Interface

            call MutexInit( 1 )
            call MutexLock( 1 )
            call MutexUnlock( 1 )
            ...