Pthread library

This Pthreads library is a partial and experimental implementation of the Posix.1c standard for thread programming. It is only intented for educational purposes, not for really productive applications. I wrote this library to show internal details while presenting courses of system programming.

The library is totally implemented in user space, using none of the system call (like clone(2)) provided by the kernel to help implement threads library. It only works on Intel based Linux systems, because of the processor dependant stack handling.

All the typedef and functions use the “Pthread_” prefix, while the real Posix.1c implementations use the “pthread_” prefix. This is intented to avoid confusion when the C library automatically includes “pthread_” typedefs. So the Pthreads library can be installed on a system that has already a pthread library. A shell script named is provided to convert the source files, with the help of the Sed tool.

The library uses the SIGALRM signal to schedule the threads. So you must not uses this signal, nor the ITIMER_REAL timer in your application. In fact, I suspect that a large part of the sleeping system calls and functions won’t work (sleep(3)usleep(3)setitimer(2)…)

Note that most of the Posix.1c functions are not implemented yet, the scheduler is ridiculous, a thousand of bugs are still there, but I think that the Pthreads library can be useful to understand how a real user-space thread libraries could be built.


This library is only interesting for source code studying, so I do not provide any binary-only package!




URL de trackback pour cette page