Programming with POSIX Threads: David R. Butenhof
C
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
Makefile initial import Mar 28, 2013
README initial import Mar 28, 2013
alarm.c initial import Mar 28, 2013
alarm_cond.c initial import Mar 28, 2013
alarm_fork.c initial import Mar 28, 2013
alarm_mutex.c initial import Mar 28, 2013
alarm_thread.c initial import Mar 28, 2013
atfork.c initial import Mar 28, 2013
backoff.c initial import Mar 28, 2013
barrier.c initial import Mar 28, 2013
barrier.h initial import Mar 28, 2013
barrier_main.c initial import Mar 28, 2013
cancel.c initial import Mar 28, 2013
cancel_async.c initial import Mar 28, 2013
cancel_cleanup.c initial import Mar 28, 2013
cancel_disable.c initial import Mar 28, 2013
cancel_subcontract.c initial import Mar 28, 2013
cond.c initial import Mar 28, 2013
cond_attr.c initial import Mar 28, 2013
cond_dynamic.c initial import Mar 28, 2013
cond_static.c initial import Mar 28, 2013
crew.c initial import Mar 28, 2013
errors.h initial import Mar 28, 2013
flock.c initial import Mar 28, 2013
getlogin.c initial import Mar 28, 2013
hello.c initial import Mar 28, 2013
inertia.c initial import Mar 28, 2013
lifecycle.c initial import Mar 28, 2013
mutex_attr.c initial import Mar 28, 2013
mutex_dynamic.c initial import Mar 28, 2013
mutex_static.c initial import Mar 28, 2013
once.c initial import Mar 28, 2013
pipe.c initial import Mar 28, 2013
putchar.c initial import Mar 28, 2013
rwlock.c initial import Mar 28, 2013
rwlock.h initial import Mar 28, 2013
rwlock_main.c initial import Mar 28, 2013
rwlock_try_main.c initial import Mar 28, 2013
sched_attr.c initial import Mar 28, 2013
sched_thread.c initial import Mar 28, 2013
semaphore_signal.c initial import Mar 28, 2013
semaphore_wait.c initial import Mar 28, 2013
server.c initial import Mar 28, 2013
sigev_thread.c initial import Mar 28, 2013
sigwait.c initial import Mar 28, 2013
susp.c initial import Mar 28, 2013
thread.c initial import Mar 28, 2013
thread_attr.c initial import Mar 28, 2013
thread_error.c initial import Mar 28, 2013
trylock.c initial import Mar 28, 2013
tsd_destructor.c initial import Mar 28, 2013
tsd_once.c initial import Mar 28, 2013
workq.c initial import Mar 28, 2013
workq.h initial import Mar 28, 2013
workq_main.c initial import Mar 28, 2013

README

These are the source files for the programming examples in
"Programming With POSIX(r) Threads". The Makefile is pre-configured
for Digital UNIX, but includes the appropriate definitions to build on
Solaris (uncomment the Solaris lines and comment the Digital UNIX
lines).

alarm.c				Simple synchronous alarm clock
alarm_cond.c			Threaded alarm clock using condition variable
alarm_fork.c			Alarm clock using fork asychrony
alarm_mutex.c			Threaded alarm clock using mutex
alarm_thread.c			Alarm clock using thread asynchrony
atfork.c			Demonstrate pthread_atfork()
backoff.c			Demonstrate mutex hierarchy backoff
barrier.c			Implementation of barrier package
barrier_main.c			Demonstrate use of barrier package
cancel.c			Demonstrate cancellation
cancel_async.c			Demonstrate asyncronous cancellation
cancel_cleanup.c		Demonstrate cancellation cleanup
cancel_disable.c		Demonstrate disabling cancellation
cancel_subcontract.c		Demonstrate cancellation of "subcontractors"
cond.c				Demonstrate use of condition variables
cond_attr.c			Demonstrate condition variable attributes
cond_dynamic.c			Demonstrate dynamic init of condition variable
cond_static.c			Demonstrate static init of condition variable
crew.c				A simple threaded work crew
flock.c				Demonstrate use of file locking
getlogin.c			Demonstrate reentrant user functions
hello.c				Demonstrate thread creation
inertia.c			Demonstrate "thread inertia" errors
lifecycle.c			Demonstrate "thread lifecycle"
mutex_attr.c			Demonstrate mutex attributes
mutex_dynamic.c			Demonstrate dynamic initialization of mutex
mutex_static.c			Demonstrate static initialization of mutex
once.c				Demonstrate use of pthread_once()
pipe.c				A simple threaded pipeline
putchar.c			Demonstrate thread-safe use of putchar()
rwlock.c			Implementation of read/write lock package
rwlock_main.c			Demonstrate use of read/write lock package
rwlock_try_main.c		Demonstrate use of read/write lock package
sched_attr.c			Demonstrate thread scheduling attributes
sched_thread.c			Demonstrate use of thread scheduling functions
semaphore_signal.c		Demonstrate use of semaphores with signals
semaphore_wait.c		Demonstrate use of semaphores
server.c			A simple threaded client/server program
sigev_thread.c			Demonstrate use of SIGEV_THREAD mechanism
sigwait.c			Demonstrate use of sigwait()
susp.c				Demonstrate use of pthread_kill()
thread.c			Demonstrate simple concurrent I/O
thread_attr.c			Demonstrate thread attributes
thread_error.c			Demonstrate POSIX thread error mechanism
trylock.c			Demonstrate use of pthread_mutex_trylock()
tsd_destructor.c		Demonstrate thread-specific data destructors
tsd_once.c			Demonstrate thread-specific data key creation
workq.c				Implementation of work queue package
workq_main.c			Demonstrate use of work queue package

Header files:

barrier.h			Definitions for barrier package
errors.h			General headers and error macros
rwlock.h			Definitions for read/write lock package
workq.h				Definitions for work queue package

Programs with arguments or special behavior:

alarm, alarm_fork,		The alarm programs will prompt for
alarm_thread, alarm_mutex,	commands until terminated by ^D
alarm_cond			(EOF). Commands are "<n> <s>" where <s>
				(the remainder of the line) is a
				message to print after <n> seconds.
atfork [hang]			Run with an argument of 0 to omit
				atfork handlers -- program will hang.
backoff [backoff [delay]]	Run with first argument of 0, will not
				back off on mutex collision, and will
				usually hang. Second argument can be
				specified greater than 0 to yield
				(increasing chances of hang on
				uniprocessor), or less than 0 to sleep
				for a second.
crew string path		First argument is a search string,
				second is a file path.
flock				Threads will prompt alternately for
				input.
pipe				Prompts for integers to feed to
				pipeline; enter "=" to pop a result.
putchar [unsync]		Run with argument of 0 to concurrently
				call putchar_unlocked from multiple
				threads.
server				Threads each prompt for input, and
				echo it 3 times -- server prevents
				output while waiting for input.
sigwait				Waits for 5 SIGINT signals (^C)
thread				One thread writes to stdout while
				another waits for input from
				stdin. (Satisfy the read to exit.)

/---[ Dave Butenhof ]-----------------------[ butenhof@zko.dec.com ]---\
| Digital Equipment Corporation           110 Spit Brook Rd ZKO2-3/Q18 |
| 603.881.2218, FAX 603.881.0120                  Nashua NH 03062-2698 |
\-----------------[ Better Living Through Concurrency ]----------------/