Deutsch |
These programming examples show how to use some basic Posix Threads API calls. They are published under the GNU General Public License. They are intended as examples only; they are not intended for productive use. These examples come with absolutely no warranty.
5threads.c
Creating 5 threads
5threads_prio.c
Creating 5 SCHED_FIFO threads (as root)
a_thread.c
Creating a thread
async_cancel.c
Asynchronous cancellation
bad_main.c
Bad program: race condition with main thread
bad_threadname.c
Bad program: function threadname() not reentrant
barrier.c
Barrier
cnt_atomic.c
Use atomic add instead of mutex
cnt_fix.c
How to use a mutex
cond_wait_cancel.c
Deferred cancelation
condition.c
How to use a condition
countdown.c, countdown2.c
More condition examples
deadlock.c
Deadlock demo
fairlock.C
C++ program: uses classes to implement a fair lock
join_main.c
How to use pthread_join
killthread.c
Route an external signal to a thread
liste.c
Multithreaded linear list
malloc_mutex.c
Malloced mutex
other_prio.c
Mutexes and priorities in SCHED_OTHER
pause0.c, pause0.c
More condition example
preempt_ctl.c
Solaris LWP preemption control
prod_cons.c, prod_cons2.c, prod_cons_int.c, no_prod_cons.c
Producer / consumer examples
random_add.c, random_add_ser.c
Adding random numbers in parallel
rdtimeout.c
Read from tty with timeout thread
robust_mutex.c
Robust mutex
setsolprio.c
Setting Solaris priorities for LWPs
sigtest.c
Testing signals and threads
sigwait.c
Using sigwait
spurious_wakeup.c
A "spurious wakeup"
stacksize.c, stksz.c
Setting and testing the stack size
tsd.c
Thread specific data
turn.c
Taking turns with mutex and condition
unfair_mutex.c
Demo: mutexes are unfair