{"id":229,"date":"2011-03-04T14:34:54","date_gmt":"2011-03-04T13:34:54","guid":{"rendered":"http:\/\/www.blaess.fr\/christophe\/blog\/?page_id=229"},"modified":"2011-03-04T14:34:54","modified_gmt":"2011-03-04T13:34:54","slug":"pthread-library","status":"publish","type":"page","link":"https:\/\/www.blaess.fr\/christophe\/developpements\/pthread-library\/","title":{"rendered":"Pthread library"},"content":{"rendered":"<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">The library is totally implemented in user space, using none of the system call (like\u00a0<code>clone(2)<\/code>) provided by the kernel to help implement threads library. It only works on Intel based Linux systems, because of the processor dependant stack handling.<\/p>\n<p style=\"text-align: justify;\">All the\u00a0<em>typedef<\/em> and functions use the \u00ab\u00a0<code>Pthread_<\/code>\u00a0\u00bb prefix, while the real Posix.1c implementations use the \u00ab\u00a0<code>pthread_<\/code>\u00a0\u00bb prefix. This is intented to avoid confusion when the C library automatically includes \u00ab\u00a0<code>pthread_<\/code>\u00a0\u00bb\u00a0<em>typedefs<\/em>. So the Pthreads library can be installed on a system that has already a pthread library. A shell script named\u00a0<code>pthread_2_Pthread.sh<\/code> is provided to convert the source files, with the help of the Sed tool.<\/p>\n<p style=\"text-align: justify;\">The library uses the\u00a0<code>SIGALRM<\/code> signal to schedule the threads. So you must not uses this signal, nor the\u00a0<code>ITIMER_REAL<\/code> timer in your application. In fact, I suspect that a large part of the sleeping system calls and functions won&rsquo;t work (<code>sleep(3)<\/code>,\u00a0<code>usleep(3)<\/code>,\u00a0<code>setitimer(2)<\/code>\u2026)<\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<h1>Download<\/h1>\n<p style=\"text-align: justify;\">This library is only interesting for source code studying, so I do not provide any binary-only package!<\/p>\n<ul>\n<li><a href=\"http:\/\/www.blaess.fr\/christophe\/files\/Pthreads-library-1.0.tar.gz\">Download Pthreads library source code<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"parent":196,"menu_order":2,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-229","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.blaess.fr\/christophe\/wp-json\/wp\/v2\/pages\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blaess.fr\/christophe\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.blaess.fr\/christophe\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.blaess.fr\/christophe\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blaess.fr\/christophe\/wp-json\/wp\/v2\/comments?post=229"}],"version-history":[{"count":0,"href":"https:\/\/www.blaess.fr\/christophe\/wp-json\/wp\/v2\/pages\/229\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.blaess.fr\/christophe\/wp-json\/wp\/v2\/pages\/196"}],"wp:attachment":[{"href":"https:\/\/www.blaess.fr\/christophe\/wp-json\/wp\/v2\/media?parent=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}