\hypertarget{opal_2threads_2mutex_8h}{\section{opal/threads/mutex.h File Reference}
\label{opal_2threads_2mutex_8h}\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
}


Mutual exclusion functions.  


{\ttfamily \#include \char`\"{}opal\+\_\+config.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}mutex\+\_\+unix.\+h\char`\"{}}\\*
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads}()~opal\+\_\+uses\+\_\+threads
\begin{DoxyCompactList}\small\item\em Check and see if the process is using multiple threads. \end{DoxyCompactList}\item 
\#define \hyperlink{opal_2threads_2mutex_8h_a77efbafa6bfd030f2fca7658458a1f6d}{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+L\+O\+C\+K}(mutex)
\begin{DoxyCompactList}\small\item\em Lock a mutex if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} says that multiple threads may be active in the process. \end{DoxyCompactList}\item 
\#define \hyperlink{opal_2threads_2mutex_8h_a98ed0ab082e21d4c3b9454edc9bd0da9}{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+T\+R\+Y\+L\+O\+C\+K}(mutex)~0
\begin{DoxyCompactList}\small\item\em Try to lock a mutex if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} says that multiple threads may be active in the process. \end{DoxyCompactList}\item 
\#define \hyperlink{opal_2threads_2mutex_8h_a26cea76373139434c7f03b24a58b6c04}{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+U\+N\+L\+O\+C\+K}(mutex)
\begin{DoxyCompactList}\small\item\em Unlock a mutex if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} says that multiple threads may be active in the process. \end{DoxyCompactList}\item 
\#define \hyperlink{opal_2threads_2mutex_8h_afad6b9c403459ec0c46985b5be75d917}{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+S\+C\+O\+P\+E\+D\+\_\+\+L\+O\+C\+K}(mutex, action)~(action)
\begin{DoxyCompactList}\small\item\em Lock a mutex if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} says that multiple threads may be active in the process for the duration of the specified action. \end{DoxyCompactList}\item 
\hypertarget{opal_2threads_2mutex_8h_a514288878869c0997f029d56eb4a63ee}{\#define \hyperlink{opal_2threads_2mutex_8h_a514288878869c0997f029d56eb4a63ee}{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+A\+D\+D32}(x, y)~($\ast$x += y)}\label{opal_2threads_2mutex_8h_a514288878869c0997f029d56eb4a63ee}

\begin{DoxyCompactList}\small\item\em Use an atomic operation for increment/decrement if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} indicates that threads are in use by the application or library. \end{DoxyCompactList}\item 
\hypertarget{opal_2threads_2mutex_8h_a7715dbf4007f010e8b47602941b75592}{\#define {\bfseries O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+A\+D\+D64}(x, y)~($\ast$x += y)}\label{opal_2threads_2mutex_8h_a7715dbf4007f010e8b47602941b75592}

\item 
\hypertarget{opal_2threads_2mutex_8h_a11ff596d1c27f352b8238639fb9330ab}{\#define {\bfseries O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+A\+D\+D\+\_\+\+S\+I\+Z\+E\+\_\+\+T}(x, y)~($\ast$x += y)}\label{opal_2threads_2mutex_8h_a11ff596d1c27f352b8238639fb9330ab}

\item 
\hypertarget{opal_2threads_2mutex_8h_ac079aac30a26f8c4dc220ca8bf1b6607}{\#define {\bfseries O\+P\+A\+L\+\_\+\+C\+M\+P\+S\+E\+T}(x, y, z)~(($\ast$(x) == (y)) ? (($\ast$(x) = (z)), 1) \+: 0)}\label{opal_2threads_2mutex_8h_ac079aac30a26f8c4dc220ca8bf1b6607}

\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\hypertarget{opal_2threads_2mutex_8h_a62c2a5dce3bb57f8d28e219d4cb145cc}{typedef struct \hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} \hyperlink{opal_2threads_2mutex_8h_a62c2a5dce3bb57f8d28e219d4cb145cc}{opal\+\_\+mutex\+\_\+t}}\label{opal_2threads_2mutex_8h_a62c2a5dce3bb57f8d28e219d4cb145cc}

\begin{DoxyCompactList}\small\item\em Opaque mutex object. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int \hyperlink{opal_2threads_2mutex_8h_abcb62f36a971d3f918c245ba2a44d8e6}{opal\+\_\+mutex\+\_\+trylock} (\hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} $\ast$mutex)
\begin{DoxyCompactList}\small\item\em Try to acquire a mutex. \end{DoxyCompactList}\item 
static void \hyperlink{opal_2threads_2mutex_8h_a793ca98a77bec7d8fdad2998176f2d3d}{opal\+\_\+mutex\+\_\+lock} (\hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} $\ast$mutex)
\begin{DoxyCompactList}\small\item\em Acquire a mutex. \end{DoxyCompactList}\item 
static void \hyperlink{opal_2threads_2mutex_8h_a037d4ef3c5a908ddb18c53cca6490bea}{opal\+\_\+mutex\+\_\+unlock} (\hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} $\ast$mutex)
\begin{DoxyCompactList}\small\item\em Release a mutex. \end{DoxyCompactList}\item 
static int \hyperlink{opal_2threads_2mutex_8h_a5bece6296f9f733e923a38b4e6aaa23d}{opal\+\_\+mutex\+\_\+atomic\+\_\+trylock} (\hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} $\ast$mutex)
\begin{DoxyCompactList}\small\item\em Try to acquire a mutex using atomic operations. \end{DoxyCompactList}\item 
static void \hyperlink{opal_2threads_2mutex_8h_adc5fee69c645227096fc5ba422949ecc}{opal\+\_\+mutex\+\_\+atomic\+\_\+lock} (\hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} $\ast$mutex)
\begin{DoxyCompactList}\small\item\em Acquire a mutex using atomic operations. \end{DoxyCompactList}\item 
static void \hyperlink{opal_2threads_2mutex_8h_aba898523077f39bdbffecde8bd659bcd}{opal\+\_\+mutex\+\_\+atomic\+\_\+unlock} (\hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} $\ast$mutex)
\begin{DoxyCompactList}\small\item\em Release a mutex using atomic operations. \end{DoxyCompactList}\item 
static bool \hyperlink{opal_2threads_2mutex_8h_ac2e27b961f22bc8d66b5a1f9a5a479ca}{opal\+\_\+set\+\_\+using\+\_\+threads} (bool have)
\begin{DoxyCompactList}\small\item\em Set whether the process is using multiple threads or not. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\hypertarget{opal_2threads_2mutex_8h_a921775653303df61ba86edb6638c8df6}{O\+P\+A\+L\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C bool {\bfseries opal\+\_\+uses\+\_\+threads}}\label{opal_2threads_2mutex_8h_a921775653303df61ba86edb6638c8df6}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
Mutual exclusion functions. 

Functions for locking of critical sections. 

\subsection{Macro Definition Documentation}
\hypertarget{opal_2threads_2mutex_8h_a77efbafa6bfd030f2fca7658458a1f6d}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+L\+O\+C\+K@{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+L\+O\+C\+K}}
\index{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+L\+O\+C\+K@{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+L\+O\+C\+K}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+L\+O\+C\+K}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+L\+O\+C\+K(
\begin{DoxyParamCaption}
\item[{}]{mutex}
\end{DoxyParamCaption}
)}}\label{opal_2threads_2mutex_8h_a77efbafa6bfd030f2fca7658458a1f6d}


Lock a mutex if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} says that multiple threads may be active in the process. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Pointer to a \hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} to lock.\\
\hline
\end{DoxyParams}
If there is a possibility that multiple threads are running in the process (as determined by \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()}), this function will block waiting to lock the mutex.

If there is no possibility that multiple threads are running in the process, return immediately. 

Referenced by mca\+\_\+allocator\+\_\+basic\+\_\+alloc(), mca\+\_\+allocator\+\_\+basic\+\_\+free(), mca\+\_\+allocator\+\_\+bucket\+\_\+alloc(), mca\+\_\+allocator\+\_\+bucket\+\_\+alloc\+\_\+align(), mca\+\_\+allocator\+\_\+bucket\+\_\+cleanup(), mca\+\_\+allocator\+\_\+bucket\+\_\+free(), mca\+\_\+btl\+\_\+elan\+\_\+component\+\_\+progress(), mca\+\_\+btl\+\_\+gm\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+gm\+\_\+component\+\_\+init(), mca\+\_\+btl\+\_\+gm\+\_\+component\+\_\+progress(), mca\+\_\+btl\+\_\+gm\+\_\+finalize(), mca\+\_\+btl\+\_\+gm\+\_\+get(), mca\+\_\+btl\+\_\+gm\+\_\+put(), mca\+\_\+btl\+\_\+gm\+\_\+send(), mca\+\_\+btl\+\_\+mx\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+sctp\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+tcp\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+template\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+ud\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+ud\+\_\+component\+\_\+progress(), mca\+\_\+btl\+\_\+udapl\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+udapl\+\_\+component\+\_\+progress(), mca\+\_\+btl\+\_\+udapl\+\_\+put(), mca\+\_\+mpool\+\_\+base\+\_\+tree\+\_\+find(), mca\+\_\+mpool\+\_\+grdma\+\_\+deregister(), mca\+\_\+mpool\+\_\+grdma\+\_\+finalize(), mca\+\_\+mpool\+\_\+grdma\+\_\+find(), mca\+\_\+mpool\+\_\+grdma\+\_\+register(), mca\+\_\+mpool\+\_\+grdma\+\_\+release\+\_\+memory(), mca\+\_\+mpool\+\_\+rdma\+\_\+deregister(), mca\+\_\+mpool\+\_\+rdma\+\_\+finalize(), mca\+\_\+mpool\+\_\+rdma\+\_\+find(), mca\+\_\+mpool\+\_\+rdma\+\_\+register(), mca\+\_\+mpool\+\_\+rdma\+\_\+release\+\_\+memory(), mca\+\_\+mpool\+\_\+rgpusm\+\_\+deregister(), mca\+\_\+mpool\+\_\+rgpusm\+\_\+finalize(), mca\+\_\+mpool\+\_\+rgpusm\+\_\+find(), mca\+\_\+mpool\+\_\+rgpusm\+\_\+register(), mca\+\_\+oob\+\_\+tcp\+\_\+fini(), mca\+\_\+oob\+\_\+tcp\+\_\+msg\+\_\+complete(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+accept(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+lookup(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+resolved(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+send(), mca\+\_\+oob\+\_\+tcp\+\_\+recv\+\_\+cancel(), mca\+\_\+oob\+\_\+tcp\+\_\+recv\+\_\+nb(), mca\+\_\+oob\+\_\+tcp\+\_\+resolve(), mca\+\_\+oob\+\_\+tcp\+\_\+set\+\_\+addr(), mca\+\_\+pml\+\_\+bfo\+\_\+error\+\_\+pending\+\_\+packets(), mca\+\_\+pml\+\_\+bfo\+\_\+recv\+\_\+frag\+\_\+callback\+\_\+match(), mca\+\_\+pml\+\_\+bfo\+\_\+recv\+\_\+frag\+\_\+match(), mca\+\_\+pml\+\_\+bfo\+\_\+recv\+\_\+req\+\_\+start(), mca\+\_\+pml\+\_\+bfo\+\_\+send\+\_\+request\+\_\+restart(), mca\+\_\+pml\+\_\+bfo\+\_\+start(), mca\+\_\+pml\+\_\+csum\+\_\+recv\+\_\+frag\+\_\+callback\+\_\+match(), mca\+\_\+pml\+\_\+csum\+\_\+recv\+\_\+frag\+\_\+match(), mca\+\_\+pml\+\_\+csum\+\_\+recv\+\_\+req\+\_\+start(), mca\+\_\+pml\+\_\+csum\+\_\+start(), mca\+\_\+pml\+\_\+ob1\+\_\+recv\+\_\+frag\+\_\+callback\+\_\+match(), mca\+\_\+pml\+\_\+ob1\+\_\+recv\+\_\+frag\+\_\+match(), mca\+\_\+pml\+\_\+ob1\+\_\+recv\+\_\+req\+\_\+start(), mca\+\_\+pml\+\_\+ob1\+\_\+start(), ompi\+\_\+attr\+\_\+copy\+\_\+all(), ompi\+\_\+attr\+\_\+delete(), ompi\+\_\+attr\+\_\+delete\+\_\+all(), ompi\+\_\+attr\+\_\+free\+\_\+keyval(), ompi\+\_\+proc\+\_\+all(), ompi\+\_\+proc\+\_\+complete\+\_\+init(), ompi\+\_\+proc\+\_\+find(), ompi\+\_\+proc\+\_\+pack(), ompi\+\_\+proc\+\_\+refresh(), ompi\+\_\+proc\+\_\+world(), ompi\+\_\+request\+\_\+wait\+\_\+completion(), opal\+\_\+output\+\_\+close(), opal\+\_\+pointer\+\_\+array\+\_\+add(), opal\+\_\+pointer\+\_\+array\+\_\+get\+\_\+item(), opal\+\_\+pointer\+\_\+array\+\_\+remove\+\_\+all(), opal\+\_\+pointer\+\_\+array\+\_\+set\+\_\+item(), opal\+\_\+pointer\+\_\+array\+\_\+set\+\_\+size(), opal\+\_\+pointer\+\_\+array\+\_\+test\+\_\+and\+\_\+set\+\_\+item(), opal\+\_\+util\+\_\+keyval\+\_\+parse(), orte\+\_\+odls\+\_\+base\+\_\+default\+\_\+signal\+\_\+local\+\_\+procs(), orte\+\_\+plm\+\_\+submit\+\_\+launch(), and recv\+\_\+request\+\_\+pml\+\_\+complete().

\hypertarget{opal_2threads_2mutex_8h_afad6b9c403459ec0c46985b5be75d917}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+S\+C\+O\+P\+E\+D\+\_\+\+L\+O\+C\+K@{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+S\+C\+O\+P\+E\+D\+\_\+\+L\+O\+C\+K}}
\index{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+S\+C\+O\+P\+E\+D\+\_\+\+L\+O\+C\+K@{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+S\+C\+O\+P\+E\+D\+\_\+\+L\+O\+C\+K}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+S\+C\+O\+P\+E\+D\+\_\+\+L\+O\+C\+K}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+S\+C\+O\+P\+E\+D\+\_\+\+L\+O\+C\+K(
\begin{DoxyParamCaption}
\item[{}]{mutex, }
\item[{}]{action}
\end{DoxyParamCaption}
)~(action)}}\label{opal_2threads_2mutex_8h_afad6b9c403459ec0c46985b5be75d917}


Lock a mutex if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} says that multiple threads may be active in the process for the duration of the specified action. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Pointer to a \hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} to lock. \\
\hline
{\em action} & A scope over which the lock is held.\\
\hline
\end{DoxyParams}
If there is a possibility that multiple threads are running in the process (as determined by \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()}), this function will acquire the lock before invoking the specified action and release it on return.

If there is no possibility that multiple threads are running in the process, invoke the action without acquiring the lock. \hypertarget{opal_2threads_2mutex_8h_a98ed0ab082e21d4c3b9454edc9bd0da9}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+T\+R\+Y\+L\+O\+C\+K@{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+T\+R\+Y\+L\+O\+C\+K}}
\index{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+T\+R\+Y\+L\+O\+C\+K@{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+T\+R\+Y\+L\+O\+C\+K}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+T\+R\+Y\+L\+O\+C\+K}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+T\+R\+Y\+L\+O\+C\+K(
\begin{DoxyParamCaption}
\item[{}]{mutex}
\end{DoxyParamCaption}
)~0}}\label{opal_2threads_2mutex_8h_a98ed0ab082e21d4c3b9454edc9bd0da9}


Try to lock a mutex if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} says that multiple threads may be active in the process. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Pointer to a \hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} to trylock\\
\hline
\end{DoxyParams}
If there is a possibility that multiple threads are running in the process (as determined by \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()}), this function will trylock the mutex.

If there is no possibility that multiple threads are running in the process, return immediately without modifying the mutex.

Returns 0 if mutex was locked, non-\/zero otherwise. 

Referenced by mca\+\_\+btl\+\_\+elan\+\_\+component\+\_\+progress().

\hypertarget{opal_2threads_2mutex_8h_a26cea76373139434c7f03b24a58b6c04}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+U\+N\+L\+O\+C\+K@{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+U\+N\+L\+O\+C\+K}}
\index{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+U\+N\+L\+O\+C\+K@{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+U\+N\+L\+O\+C\+K}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+U\+N\+L\+O\+C\+K}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+P\+A\+L\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+U\+N\+L\+O\+C\+K(
\begin{DoxyParamCaption}
\item[{}]{mutex}
\end{DoxyParamCaption}
)}}\label{opal_2threads_2mutex_8h_a26cea76373139434c7f03b24a58b6c04}


Unlock a mutex if \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} says that multiple threads may be active in the process. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Pointer to a \hyperlink{structopal__mutex__t}{opal\+\_\+mutex\+\_\+t} to unlock.\\
\hline
\end{DoxyParams}
If there is a possibility that multiple threads are running in the process (as determined by \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()}), this function will unlock the mutex.

If there is no possibility that multiple threads are running in the process, return immediately without modifying the mutex. 

Referenced by mca\+\_\+allocator\+\_\+basic\+\_\+alloc(), mca\+\_\+allocator\+\_\+basic\+\_\+free(), mca\+\_\+allocator\+\_\+bucket\+\_\+alloc(), mca\+\_\+allocator\+\_\+bucket\+\_\+alloc\+\_\+align(), mca\+\_\+allocator\+\_\+bucket\+\_\+cleanup(), mca\+\_\+allocator\+\_\+bucket\+\_\+free(), mca\+\_\+btl\+\_\+elan\+\_\+component\+\_\+progress(), mca\+\_\+btl\+\_\+gm\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+gm\+\_\+component\+\_\+init(), mca\+\_\+btl\+\_\+gm\+\_\+component\+\_\+progress(), mca\+\_\+btl\+\_\+gm\+\_\+finalize(), mca\+\_\+btl\+\_\+gm\+\_\+get(), mca\+\_\+btl\+\_\+gm\+\_\+put(), mca\+\_\+btl\+\_\+gm\+\_\+send(), mca\+\_\+btl\+\_\+mx\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+sctp\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+tcp\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+template\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+ud\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+ud\+\_\+component\+\_\+progress(), mca\+\_\+btl\+\_\+udapl\+\_\+add\+\_\+procs(), mca\+\_\+btl\+\_\+udapl\+\_\+component\+\_\+progress(), mca\+\_\+btl\+\_\+udapl\+\_\+put(), mca\+\_\+mpool\+\_\+base\+\_\+tree\+\_\+find(), mca\+\_\+mpool\+\_\+grdma\+\_\+deregister(), mca\+\_\+mpool\+\_\+grdma\+\_\+finalize(), mca\+\_\+mpool\+\_\+grdma\+\_\+find(), mca\+\_\+mpool\+\_\+grdma\+\_\+register(), mca\+\_\+mpool\+\_\+grdma\+\_\+release\+\_\+memory(), mca\+\_\+mpool\+\_\+rdma\+\_\+deregister(), mca\+\_\+mpool\+\_\+rdma\+\_\+finalize(), mca\+\_\+mpool\+\_\+rdma\+\_\+find(), mca\+\_\+mpool\+\_\+rdma\+\_\+register(), mca\+\_\+mpool\+\_\+rdma\+\_\+release\+\_\+memory(), mca\+\_\+mpool\+\_\+rgpusm\+\_\+deregister(), mca\+\_\+mpool\+\_\+rgpusm\+\_\+finalize(), mca\+\_\+mpool\+\_\+rgpusm\+\_\+find(), mca\+\_\+mpool\+\_\+rgpusm\+\_\+register(), mca\+\_\+oob\+\_\+tcp\+\_\+fini(), mca\+\_\+oob\+\_\+tcp\+\_\+msg\+\_\+complete(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+accept(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+close(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+lookup(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+resolved(), mca\+\_\+oob\+\_\+tcp\+\_\+peer\+\_\+send(), mca\+\_\+oob\+\_\+tcp\+\_\+recv\+\_\+cancel(), mca\+\_\+oob\+\_\+tcp\+\_\+recv\+\_\+nb(), mca\+\_\+oob\+\_\+tcp\+\_\+resolve(), mca\+\_\+oob\+\_\+tcp\+\_\+set\+\_\+addr(), mca\+\_\+pml\+\_\+bfo\+\_\+error\+\_\+pending\+\_\+packets(), mca\+\_\+pml\+\_\+bfo\+\_\+recv\+\_\+frag\+\_\+callback\+\_\+match(), mca\+\_\+pml\+\_\+bfo\+\_\+recv\+\_\+frag\+\_\+match(), mca\+\_\+pml\+\_\+bfo\+\_\+recv\+\_\+req\+\_\+start(), mca\+\_\+pml\+\_\+bfo\+\_\+send\+\_\+request\+\_\+restart(), mca\+\_\+pml\+\_\+bfo\+\_\+start(), mca\+\_\+pml\+\_\+csum\+\_\+recv\+\_\+frag\+\_\+callback\+\_\+match(), mca\+\_\+pml\+\_\+csum\+\_\+recv\+\_\+frag\+\_\+match(), mca\+\_\+pml\+\_\+csum\+\_\+recv\+\_\+req\+\_\+start(), mca\+\_\+pml\+\_\+csum\+\_\+start(), mca\+\_\+pml\+\_\+ob1\+\_\+recv\+\_\+frag\+\_\+callback\+\_\+match(), mca\+\_\+pml\+\_\+ob1\+\_\+recv\+\_\+frag\+\_\+match(), mca\+\_\+pml\+\_\+ob1\+\_\+recv\+\_\+req\+\_\+start(), mca\+\_\+pml\+\_\+ob1\+\_\+start(), ompi\+\_\+attr\+\_\+copy\+\_\+all(), ompi\+\_\+attr\+\_\+delete(), ompi\+\_\+attr\+\_\+delete\+\_\+all(), ompi\+\_\+attr\+\_\+free\+\_\+keyval(), ompi\+\_\+proc\+\_\+all(), ompi\+\_\+proc\+\_\+complete\+\_\+init(), ompi\+\_\+proc\+\_\+find(), ompi\+\_\+proc\+\_\+pack(), ompi\+\_\+proc\+\_\+refresh(), ompi\+\_\+proc\+\_\+world(), ompi\+\_\+request\+\_\+wait\+\_\+completion(), opal\+\_\+output\+\_\+close(), opal\+\_\+pointer\+\_\+array\+\_\+add(), opal\+\_\+pointer\+\_\+array\+\_\+get\+\_\+item(), opal\+\_\+pointer\+\_\+array\+\_\+remove\+\_\+all(), opal\+\_\+pointer\+\_\+array\+\_\+set\+\_\+item(), opal\+\_\+pointer\+\_\+array\+\_\+set\+\_\+size(), opal\+\_\+pointer\+\_\+array\+\_\+test\+\_\+and\+\_\+set\+\_\+item(), opal\+\_\+util\+\_\+keyval\+\_\+parse(), orte\+\_\+odls\+\_\+base\+\_\+default\+\_\+signal\+\_\+local\+\_\+procs(), orte\+\_\+plm\+\_\+submit\+\_\+launch(), and recv\+\_\+request\+\_\+pml\+\_\+complete().

\hypertarget{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!opal\+\_\+using\+\_\+threads@{opal\+\_\+using\+\_\+threads}}
\index{opal\+\_\+using\+\_\+threads@{opal\+\_\+using\+\_\+threads}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{opal\+\_\+using\+\_\+threads}]{\setlength{\rightskip}{0pt plus 5cm}\#define opal\+\_\+using\+\_\+threads(
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)~opal\+\_\+uses\+\_\+threads}}\label{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}


Check and see if the process is using multiple threads. 


\begin{DoxyRetVals}{Return values}
{\em true} & If the process may have more than one thread. \\
\hline
{\em false} & If the process only has a single thread.\\
\hline
\end{DoxyRetVals}
The value that this function returns is influenced by\+:


\begin{DoxyItemize}
\item how M\+P\+I\+\_\+\+I\+N\+I\+T or M\+P\+I\+\_\+\+I\+N\+I\+T\+\_\+\+T\+H\+R\+E\+A\+D was invoked,
\item what the final M\+P\+I thread level was determined to be,
\item whether the O\+M\+P\+I or M\+P\+I libraries are multi-\/threaded (Jan 2003\+: they're not),
\item whether configure determined if we have thread support or not
\end{DoxyItemize}

M\+P\+I\+\_\+\+I\+N\+I\+T and M\+P\+I\+\_\+\+I\+N\+I\+T\+\_\+\+T\+H\+R\+E\+A\+D (specifically, back-\/end O\+M\+P\+I startup functions) invoke \hyperlink{opal_2threads_2mutex_8h_ac2e27b961f22bc8d66b5a1f9a5a479ca}{opal\+\_\+set\+\_\+using\+\_\+threads()} to influence the value of this function, depending on their situation. Some examples\+:


\begin{DoxyItemize}
\item if configure determined that we do not have threads, then this value will always be false.
\item if M\+P\+I\+\_\+\+I\+N\+I\+T is invoked, and the ompi libraries are \mbox{[}still\mbox{]} single-\/threaded, this value will be false.
\item if M\+P\+I\+\_\+\+I\+N\+I\+T\+\_\+\+T\+H\+R\+E\+A\+D is invoked with M\+P\+I\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+M\+U\+L\+T\+I\+P\+L\+E, we have thread support, and the final thread level is determined to be M\+P\+I\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+M\+U\+L\+T\+I\+P\+L\+E, this value will be true.
\item if the process is a single-\/threaded O\+M\+P\+I executable (e.\+g., mpicc), this value will be false.
\end{DoxyItemize}

Hence, this function will return false if there is guaranteed to only be one thread in the process. If there is even the possibility that we may have multiple threads, true will be returned. 

Referenced by mca\+\_\+btl\+\_\+sm\+\_\+component\+\_\+progress(), and mca\+\_\+btl\+\_\+smcuda\+\_\+component\+\_\+progress().



\subsection{Function Documentation}
\hypertarget{opal_2threads_2mutex_8h_adc5fee69c645227096fc5ba422949ecc}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!opal\+\_\+mutex\+\_\+atomic\+\_\+lock@{opal\+\_\+mutex\+\_\+atomic\+\_\+lock}}
\index{opal\+\_\+mutex\+\_\+atomic\+\_\+lock@{opal\+\_\+mutex\+\_\+atomic\+\_\+lock}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{opal\+\_\+mutex\+\_\+atomic\+\_\+lock}]{\setlength{\rightskip}{0pt plus 5cm}static void opal\+\_\+mutex\+\_\+atomic\+\_\+lock (
\begin{DoxyParamCaption}
\item[{{\bf opal\+\_\+mutex\+\_\+t} $\ast$}]{mutex}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}}\label{opal_2threads_2mutex_8h_adc5fee69c645227096fc5ba422949ecc}


Acquire a mutex using atomic operations. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Address of the mutex. \\
\hline
\end{DoxyParams}
\hypertarget{opal_2threads_2mutex_8h_a5bece6296f9f733e923a38b4e6aaa23d}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!opal\+\_\+mutex\+\_\+atomic\+\_\+trylock@{opal\+\_\+mutex\+\_\+atomic\+\_\+trylock}}
\index{opal\+\_\+mutex\+\_\+atomic\+\_\+trylock@{opal\+\_\+mutex\+\_\+atomic\+\_\+trylock}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{opal\+\_\+mutex\+\_\+atomic\+\_\+trylock}]{\setlength{\rightskip}{0pt plus 5cm}static int opal\+\_\+mutex\+\_\+atomic\+\_\+trylock (
\begin{DoxyParamCaption}
\item[{{\bf opal\+\_\+mutex\+\_\+t} $\ast$}]{mutex}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}}\label{opal_2threads_2mutex_8h_a5bece6296f9f733e923a38b4e6aaa23d}


Try to acquire a mutex using atomic operations. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Address of the mutex. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if the mutex was acquired, 1 otherwise. 
\end{DoxyReturn}
\hypertarget{opal_2threads_2mutex_8h_aba898523077f39bdbffecde8bd659bcd}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!opal\+\_\+mutex\+\_\+atomic\+\_\+unlock@{opal\+\_\+mutex\+\_\+atomic\+\_\+unlock}}
\index{opal\+\_\+mutex\+\_\+atomic\+\_\+unlock@{opal\+\_\+mutex\+\_\+atomic\+\_\+unlock}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{opal\+\_\+mutex\+\_\+atomic\+\_\+unlock}]{\setlength{\rightskip}{0pt plus 5cm}static void opal\+\_\+mutex\+\_\+atomic\+\_\+unlock (
\begin{DoxyParamCaption}
\item[{{\bf opal\+\_\+mutex\+\_\+t} $\ast$}]{mutex}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}}\label{opal_2threads_2mutex_8h_aba898523077f39bdbffecde8bd659bcd}


Release a mutex using atomic operations. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Address of the mutex. \\
\hline
\end{DoxyParams}
\hypertarget{opal_2threads_2mutex_8h_a793ca98a77bec7d8fdad2998176f2d3d}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!opal\+\_\+mutex\+\_\+lock@{opal\+\_\+mutex\+\_\+lock}}
\index{opal\+\_\+mutex\+\_\+lock@{opal\+\_\+mutex\+\_\+lock}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{opal\+\_\+mutex\+\_\+lock}]{\setlength{\rightskip}{0pt plus 5cm}static void opal\+\_\+mutex\+\_\+lock (
\begin{DoxyParamCaption}
\item[{{\bf opal\+\_\+mutex\+\_\+t} $\ast$}]{mutex}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}}\label{opal_2threads_2mutex_8h_a793ca98a77bec7d8fdad2998176f2d3d}


Acquire a mutex. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Address of the mutex. \\
\hline
\end{DoxyParams}


Referenced by opal\+\_\+cmd\+\_\+line\+\_\+get\+\_\+ninsts(), opal\+\_\+cmd\+\_\+line\+\_\+get\+\_\+param(), opal\+\_\+cmd\+\_\+line\+\_\+get\+\_\+tail(), opal\+\_\+cmd\+\_\+line\+\_\+get\+\_\+usage\+\_\+msg(), and opal\+\_\+cmd\+\_\+line\+\_\+parse().

\hypertarget{opal_2threads_2mutex_8h_abcb62f36a971d3f918c245ba2a44d8e6}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!opal\+\_\+mutex\+\_\+trylock@{opal\+\_\+mutex\+\_\+trylock}}
\index{opal\+\_\+mutex\+\_\+trylock@{opal\+\_\+mutex\+\_\+trylock}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{opal\+\_\+mutex\+\_\+trylock}]{\setlength{\rightskip}{0pt plus 5cm}static int opal\+\_\+mutex\+\_\+trylock (
\begin{DoxyParamCaption}
\item[{{\bf opal\+\_\+mutex\+\_\+t} $\ast$}]{mutex}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}}\label{opal_2threads_2mutex_8h_abcb62f36a971d3f918c245ba2a44d8e6}


Try to acquire a mutex. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Address of the mutex. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if the mutex was acquired, 1 otherwise. 
\end{DoxyReturn}
\hypertarget{opal_2threads_2mutex_8h_a037d4ef3c5a908ddb18c53cca6490bea}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!opal\+\_\+mutex\+\_\+unlock@{opal\+\_\+mutex\+\_\+unlock}}
\index{opal\+\_\+mutex\+\_\+unlock@{opal\+\_\+mutex\+\_\+unlock}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{opal\+\_\+mutex\+\_\+unlock}]{\setlength{\rightskip}{0pt plus 5cm}static void opal\+\_\+mutex\+\_\+unlock (
\begin{DoxyParamCaption}
\item[{{\bf opal\+\_\+mutex\+\_\+t} $\ast$}]{mutex}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}}\label{opal_2threads_2mutex_8h_a037d4ef3c5a908ddb18c53cca6490bea}


Release a mutex. 


\begin{DoxyParams}{Parameters}
{\em mutex} & Address of the mutex. \\
\hline
\end{DoxyParams}


Referenced by opal\+\_\+cmd\+\_\+line\+\_\+get\+\_\+ninsts(), opal\+\_\+cmd\+\_\+line\+\_\+get\+\_\+param(), opal\+\_\+cmd\+\_\+line\+\_\+get\+\_\+tail(), opal\+\_\+cmd\+\_\+line\+\_\+get\+\_\+usage\+\_\+msg(), and opal\+\_\+cmd\+\_\+line\+\_\+parse().

\hypertarget{opal_2threads_2mutex_8h_ac2e27b961f22bc8d66b5a1f9a5a479ca}{\index{opal/threads/mutex.\+h@{opal/threads/mutex.\+h}!opal\+\_\+set\+\_\+using\+\_\+threads@{opal\+\_\+set\+\_\+using\+\_\+threads}}
\index{opal\+\_\+set\+\_\+using\+\_\+threads@{opal\+\_\+set\+\_\+using\+\_\+threads}!opal/threads/mutex.\+h@{opal/threads/mutex.\+h}}
\subsubsection[{opal\+\_\+set\+\_\+using\+\_\+threads}]{\setlength{\rightskip}{0pt plus 5cm}static bool opal\+\_\+set\+\_\+using\+\_\+threads (
\begin{DoxyParamCaption}
\item[{bool}]{have}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}}\label{opal_2threads_2mutex_8h_ac2e27b961f22bc8d66b5a1f9a5a479ca}


Set whether the process is using multiple threads or not. 


\begin{DoxyParams}{Parameters}
{\em have} & Boolean indicating whether the process is using multiple threads or not.\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em opal\+\_\+using\+\_\+threads} & The new return value from \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()}.\\
\hline
\end{DoxyRetVals}
This function is used to influence the return value of \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()}. If configure detected that we have thread support, the return value of future invocations of \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} will be the parameter's value. If configure detected that we have no thread support, then the retuen from \hyperlink{opal_2threads_2mutex_8h_ad399c599a269419e6f102cebe9552da6}{opal\+\_\+using\+\_\+threads()} will always be false. 

Referenced by ompi\+\_\+mpi\+\_\+init().

