\rhead{\bf mc\_SemaphoreWait()}
\noindent
\vspace{5pt}
\rule{6.5in}{0.015in}
\noindent
\phantomsection
{\LARGE \bf mc\_SemaphoreWait()\index{mc\_SemaphoreWait()}}\\
\addcontentsline{toc}{section}{mc\_SemaphoreWait()}

\noindent
{\bf Synopsis}\\
{\bf \#include $<$libmc.h$>$}\\
{\bf int mc\_SemaphoreWait}({\bf int} $id$);\\

\noindent
{\bf Purpose}\\
This function allocates one resource from a MobileC synchronization semaphore variable.

\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}} 
$id$ & The id of the synchronization variable to lock. 
\end{tabular}
\end{description}

\noindent
{\bf Description}\\
This function allocates one resource from a previously allocated and initialized 
MobileC synchronization semaphore. If the semaphore resource count is non-zero, the resource is
immediately allocated. If the semaphore resource count is zero, the function blocks until a
resource is freed before allocating a resource and continuing. 

Note that although a MobileC synchronization variable may be used as a mutex, condition
variable, or semaphore, once it is used as a semaphore, it should only be used as a semaphore
for the remainder of its life cycle.

\noindent
{\bf Example}\\
The MC\_SemaphorePost() function usage is very similar to the other
binary space synchronization functions. Please see Chapter 
\ref{chap:synchronization} on page \pageref{chap:synchronization} 
and the demo at ``demos/agent\_semaphore\_example/'' for
more information.\\
\noindent

\noindent
{\bf See Also}\\
mc\_SemaphorePost(), mc\_SyncInit(), mc\_SyncDelete().\\

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