%
% This file was automatically produced at Feb 27 2003, 22:51:56 by
% c2latex -c hello.c
%
\documentclass[11pt,a4paper]{article}
\setlength{\textwidth}{15cm}
\setlength{\textheight}{22.5cm}
\setlength{\hoffset}{-2cm}
\setlength{\voffset}{-2cm}
\begin{document}
\expandafter\ifx\csname indentation\endcsname\relax%
\newlength{\indentation}\fi
\setlength{\indentation}{0.5em}
\begin{flushleft}
{$/\ast$\it{}$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$\mbox{}\\
$\ast$ FILE: hello.c\mbox{}\\
$\ast$ DESCRIPTION:\mbox{}\\
$\ast$   A "hello world" Pthreads program.  Demonstrates thread creation and\mbox{}\\
$\ast$   termination.\mbox{}\\
$\ast$\mbox{}\\
$\ast$ SOURCE: \mbox{}\\
$\ast$ LAST REVISED: 9/20/98 Blaise Barney\mbox{}\\
$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast$$\ast/$}\mbox{}\\
\mbox{}\\
{\tt \#include} $<${\tt{}pthread.h}$>$\mbox{}\\
{\tt \#include} $<${\tt{}stdio.h}$>$\mbox{}\\
{\tt \#define} NUM\_THREADS	5\mbox{}\\
\mbox{}\\
{\bf void} $\ast$\mbox{}\\
PrintHello( {\bf void} $\ast$threadid )\mbox{}\\
\{\mbox{}\\
\hspace*{8\indentation}printf( {\tt"$\backslash$n\%d: Hello World!$\backslash$n"}, threadid );\mbox{}\\
\hspace*{8\indentation}pthread\_exit( NULL );\mbox{}\\
\}\mbox{}\\
\mbox{}\\
{\bf int}\mbox{}\\
main( {\bf int} argc, {\bf char} $\ast$argv[] )\mbox{}\\
\{\mbox{}\\
\hspace*{8\indentation}pthread\_t threads[NUM\_THREADS];\mbox{}\\
\hspace*{8\indentation}{\bf int} rc, t;\mbox{}\\
\hspace*{8\indentation}{\bf for} ( t = 0; t $<$ NUM\_THREADS; t++ ) \{\mbox{}\\
\hspace*{16\indentation}printf( {\tt"Creating thread \%d$\backslash$n"}, t );\mbox{}\\
\hspace*{16\indentation}rc = pthread\_create( \&threads[t], NULL, PrintHello,\mbox{}\\
\hspace*{37\indentation}( {\bf void} $\ast$ ) \&t );\mbox{}\\
\hspace*{16\indentation}{\bf if} ( rc ) \{\mbox{}\\
\hspace*{24\indentation}printf\mbox{}\\
\hspace*{28\indentation}( {\tt"ERROR; return code from pthread\_create() is \%d$\backslash$n"},\mbox{}\\
\hspace*{30\indentation}rc );\mbox{}\\
\hspace*{24\indentation}exit( $-$1 );\mbox{}\\
\hspace*{16\indentation}\}\mbox{}\\
\hspace*{8\indentation}\}\mbox{}\\
\hspace*{8\indentation}pthread\_exit( NULL );\mbox{}\\
\}\mbox{}\\
\end{flushleft}
\end{document}
