Threads Example and Library
This section contains three downloadable files. Follow these links
for threads.h, threads.c,
and test.c.
Test.c just contains a simple demonstration of a C program that uses threads
and semaphores in a trivial but illustrative example. After downloading the
files, you can compile and run the example like this:
cc -pthread threads.c test.c
./a.out
Your program should be written in C++. the cc compiler for C and the
CC compiler for C++ are not completely compatible, so you'll need to
recompile the library (just once) like this:
CC -c threads.c
Then each time you edit your program, recompile it alone,
then relink and run. Like this:
CC -c hw7.cpp
CC -pthread hw7.o threads.o
./a.out