📄 mpiu_object_release_ref.tex
字号:
\startmanpage\mantitle{MPIU{\tt \char`\_}Object{\tt \char`\_}release{\tt \char`\_}ref}{tex}{10/7/2002}\manname{MPIU{\tt \char`\_}Object{\tt \char`\_}release{\tt \char`\_}ref}--- Decrement the reference count for an MPI object \subhead{Synopsis}\startvb\begin{verbatim}int MPIU_Object_release_ref( MPIU_Object_head *ptr, int *newval_ptr )\end{verbatim}\endvb\subhead{Input Parameter}\startarg{objptr }{Pointer to the object.}\par\subhead{Output Parameter}\startarg{newval{\tt \char`\_}ptr }{Pointer to the value of the reference count after decrementing.This value is either zero or non-zero. See below for details.}\subhead{Notes}In an unthreaded implementation, this function will usually be implementedas a single-statement macro. In an {\tt MPI{\tt \char`\_}THREAD{\tt \char`\_}MULTIPLE} implementation,this routine must implement an atomic decrement operation, using, forexample, a lock on datatypes or special assembly code such as\begin{verbatim} try-again: load-link refcount-address to r2 sub 1 to r2 store-conditional r2 to refcount-address if failed branch to try-again: store r2 to newval_ptr\end{verbatim}on RISC architectures or\begin{verbatim} lock dec refcount-address if zf store 0 to newval_ptr else store 1 to newval_ptr\end{verbatim}on IA32; "lock" is a special opcode prefix that forces atomicity. Thisis not a separate instruction; however, the GNU assembler expects opcodeprefixes on a separate line. {\tt zf} is the zero flag; this is set if theresult of the operation is zero. Implementing a full decrement-and-fetchwould require more code and the compare and swap instruction.\parOnce the reference count is decremented to zero, it is an error tochange it. A correct MPI program will never do that, but an incorrect one(particularly a multithreaded program with a race condition) might.\parThe following code is {\em invalid}:\begin{verbatim} MPID_Object_release_ref( datatype_ptr ); if (datatype_ptr->ref_count == 0) MPID_Datatype_free( datatype_ptr );\end{verbatim}In a multi-threaded implementation, the value of {\tt datatype{\tt \char`\_}ptr-$>$ref{\tt \char`\_}count}may have been changed by another thread, resulting in both threads calling{\tt MPID{\tt \char`\_}Datatype{\tt \char`\_}free}. Instead, use\begin{verbatim} if (MPID_Object_release_ref( datatype_ptr ) == 0) MPID_Datatype_free( datatype_ptr );\end{verbatim}\par\subhead{Module}MPID{\tt \char`\_}CORE\endmanpage
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -