16 lines
525 B
TeX
16 lines
525 B
TeX
\begin{algorithmic}[1]
|
|
\State $m \gets PTHREAD\_MUTEX\_INITIALIZER$
|
|
|
|
\Procedure{threadPrincipal}{}
|
|
\State $thread\_id \gets \Call{pthread\_create}{\textsc{travail}}$
|
|
\State $\Call{travail}{}$ \Comment{cet appel est exécuté dans le \en{thread} principal}
|
|
\State $\Call{pthread\_join}{thread\_id}$
|
|
\EndProcedure
|
|
|
|
\Procedure{travail}{}
|
|
\State $\Call{pthread\_mutex\_lock}{m}$
|
|
\State ... \Comment{modification d'une variable partagée}
|
|
\State $\Call{pthread\_mutex\_unlock}{m}$
|
|
\EndProcedure
|
|
\end{algorithmic}
|