POSIX: Difference between revisions

From miki
Jump to navigation Jump to search
Line 1: Line 1:
== PThreads ==
== PThreads ==

=== General Information ===


Links:
Links:
Line 9: Line 11:
;Advices
;Advices
* For portability, always create ''joinable'' or ''detachable'' threads by setting explicitly the thread attribute (using <code>pthread_attr_getdetachstate</code>). This provides portability as not all implementations may create threads as joinable by default.
* For portability, always create ''joinable'' or ''detachable'' threads by setting explicitly the thread attribute (using <code>pthread_attr_getdetachstate</code>). This provides portability as not all implementations may create threads as joinable by default.

=== Thread-Local Data ===
* Using ''thread-specific data'' area foreseen by POSIX, which requires first creating a key that is later used to set or get thread-specific data attached to that key (see [http://www.advancedlinuxprogramming.com/alp-folder/alp-ch04-threads.pdf Advanced Linux Programming - Ch 4])
* Using keyword '''__thread''', see [http://www.akkadia.org/drepper/tls.pdf http://www.akkadia.org/drepper/tls.pdf] (not available in all compiler, not standard C99 [http://stackoverflow.com/questions/6869391/using-thread-in-c99]).


=== Debugging ===
=== Debugging ===

Revision as of 17:00, 31 October 2012

PThreads

General Information

Links:

Advices
  • For portability, always create joinable or detachable threads by setting explicitly the thread attribute (using pthread_attr_getdetachstate). This provides portability as not all implementations may create threads as joinable by default.

Thread-Local Data

Debugging

See Debugging page.