Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is the POSIX threading api versioned and has it been updated since 1995?

I'm just now getting into threading and specifically I want to learn POSIX threads, and everything about them. As implemented in Linux. I'm looking for resources to learn about them but many of those resources are very old. Some of them date back to

  • 1996 with PThreads Programming: A POSIX Standard for Better Multiprocessing (A Nutshell Handbook)
  • 1997 with Programming with POSIX Threads

I am not asking for resources. Being that these two books are so old, I'm wondering how on topic they'd be. How is the POSIX API versioned? On Wikipedia all I see is this,

POSIX Threads is an API defined by the standard POSIX.1c, Threads extensions (IEEE Std 1003.1c-1995).

I'm not sure if that means that there are no updates since 1995 to the threading parts of POSIX or not? Is there any way to judge the relevancy of the material?

like image 698
NO WAR WITH RUSSIA Avatar asked Dec 04 '25 23:12

NO WAR WITH RUSSIA


1 Answers

At the very bottom of the Wikipedia page you reference in the "External Links" section, you will find a link to the current Posix specification of pthreads.h, which includes a history of changes. There have been a few, but the basic principles are intact. So the books you mention are probably still good learning materials. (I still have a well-thumbed copy of Programming with POSIX Threads on my bookshelf.)

As is mentioned in the comments below, C11 provides atomics and thread-local storage, which is implemented by GCC since 4.9. (Thread-local storage was previously available in GCC as an extension, so it is not that new.) The existence of thread-local storage reduces the need for the Pthreads thread-local storage interfaces, but that is a small part of the Pthreads library (and, although thread-local storage is easier to use and syntactically more convenient, it doesn't really change program structure much.)

C11 also specifies an optional threads.h header which contains threading function similar to Pthreads. However, glibc does not include this header, and the use of Pthreads is still pretty well universal, although both open- and closed-source threads.h implementation do exist. (For open source implementations, see the musl library and/or the FreeBSD implementation, available since 10.0.) Conceptually, the C11 interfaces are very similar to Pthreads; obviously, they have different names and in some cases they are simplified. However, once you've mastered Pthreads, you should have little trouble understanding any C11-threads programs you come across.

like image 106
rici Avatar answered Dec 06 '25 12:12

rici