\rhead{\bf MC\_MutexLock()}
\noindent
\vspace{5pt}
\rule{6.5in}{0.015in}
\noindent
\phantomsection
{\LARGE \bf MC\_MutexLock()\index{MC\_MutexLock()}}\\
\addcontentsline{toc}{section}{MC\_MutexLock()}
\label{api:MC_MutexLock()}

\noindent
{\bf Synopsis}\\
{\bf \#include $<$libmc.h$>$}\\
{\bf int MC\_MutexLock}({\bf MCAgency\_t} agency, {\bf int} $id$);\\

\noindent
{\bf Purpose}\\
This function locks a previously initialized Mobile-C synchronization variable 
as a mutex. 
If the mutex is already locked, the function blocks until it is
unlocked before locking the mutex and continuing. \\

\noindent
{\bf Return Value}\\
This function returns 0 on success, or non-zero if the id could not be found. \\

\noindent
{\bf Parameters}
\vspace{-0.1pt}
\begin{description}
\item
\begin{tabular}{p{10 mm}p{145 mm}} 
$agency$ & The agency in which to find the synchronization variable to lock.\\
$id$ & The id of the synchronization variable to lock. 
\end{tabular}
\end{description}

\noindent
{\bf Description}\\
This function locks the mutex part of a Mobile-C synchronization variable. 
While this is primarily used to guard a shared resource, the behaviour is 
similar to the standard POSIX mutex locking. 
Note that although a MobileC synchronization variable may assume the role of a 
mutex, condition variable, or semaphore, once a Mobile-C synchronization 
variable is used as a mutex, it should not be used as anything else for the 
rest of its life cycle.\\ 

\noindent
{\bf Example}\\
Please see Program \vref{prog:binary_sync_example_server} in 
Chapter \ref{chap:synchronization}.\\

\noindent

\noindent
{\bf See Also}\\
MC\_MutexUnlock(), MC\_SyncInit(), MC\_SyncDelete().\\

%\CPlot::\DataThreeD(), \CPlot::\DataFile(), \CPlot::\Plotting(), \plotxy().\\
