Академический Документы
Профессиональный Документы
Культура Документы
POSIX Threads
From Wikipedia, the free encyclopedia
POSIX Threads , usually referred to as Pthreads , is a POSIX standard for threads. The standard, POSIX.1c, Threads extensions (IEEE Std 1003.1c-1995), defines an API for creating and manipulating threads. Implementations of the API are available on many Unix-like POSIX-conformant operating systems such as FreeBSD, NetBSD, OpenBSD, GNU/Linux, Mac OS X and Solaris. DR-DOS and Microsoft Windows implementations also exist: within the SFU/SUA subsystem which provides a native implementation of a number of POSIX APIs, and also within third-party packages such as pthreads-w32,[1] which implements pthreads on top of existing Windows API.
Contents
1 Contents 2 Example 3 POSIX Threads for Windows 4 See also 5 References 6 Further reading 7 External links
Contents
Pthreads defines a set of C programming language types, functions and constants. It is implemented with a p t h r e a d . h( h t t p : / / o p e n g r o u p . o r g / o n l i n e p u b s / 0 0 7 9 0 8 7 9 9 / x s h / p t h r e a d . h . h t m l ) header and a thread library. There are around 100 Pthreads procedures, all prefixed "pthread_" and they can be categorized into four groups: Thread management - creating, joining threads etc. Mutexes Condition variables Synchronization between threads using read/write locks and barriers The POSIX semaphore API works with POSIX threads but is not part of threads standard, having been defined in the POSIX.1b, Real-time extensions (IEEE Std 1003.1b-1993) standard. Consequently the semaphore procedures are prefixed by "sem_" instead of "pthread_".
Example
en.wikipedia.org/wiki/POSIX_Threads 1/4
11/28/12
This program creates five threads, each executing the function TaskCode that prints the unique number of this thread to standard output. If a programmer wanted the threads to communicate with each other, this would require defining a variable outside of the scope of any of the functions, making it a global variable.
See also
en.wikipedia.org/wiki/POSIX_Threads 2/4
OpenMP Native POSIX Thread Library (NPTL) DCEThreads clone (Linux system call) Spurious wakeup Thread-local storage GNU Portable Threads FSU Pthreads Grand Central Dispatch (Apple's thread library) Beginthread (a subroutine within Windows for creating a new thread and unix thread)
References
1. ^ "Pthread Win-32: Level of standards conformance" (http://sources.redhat.com/pthreadswin32/conformance.html) . 2006-12-22. http://sources.redhat.com/pthreads-win32/conformance.html. Retrieved 2010-08-29. 2. ^ Hart, Johnson M. (2004-11-21). "Experiments with the Open Source Pthreads Library and Some Comments" (http://world.std.com/~jmhart/opensource.htm) . http://world.std.com/~jmhart/opensource.htm. Retrieved 2010-08-29. 3. ^ "pthread-win32_x64.zip Source and binary for Pthreads-w32 v2.8.0" (https://code.google.com/p/libusbwinusb-wip/downloads/detail?name=pthread-win32_x64.zip&can=2&q=) . 2010-01-26. https://code.google.com/p/libusb-winusb-wip/downloads/detail?name=pthread-win32_x64.zip&can=2&q=. Retrieved 2010-08-29. 4. ^ "Forum discussion: pthreads-on-64bit-Windows" (http://libusb.6.n5.nabble.com/pthreads-on-64bit-Windowstd48i20.html) . 2010-01-26. http://libusb.6.n5.nabble.com/pthreads-on-64bit-Windows-td48i20.html. Retrieved 2010-08-29. 5. ^ https://sourceforge.net/apps/trac/mingw-w64/wiki/Compile%20pthreads 6. ^ http://sourceware.org/pthreads-win32/news.html -- the "64 bit" mentions 7. ^ "Chapter 1: Introduction to Windows Services for UNIX 3.5" (http://technet.microsoft.com/enus/library/bb496994.aspx) . http://technet.microsoft.com/en-us/library/bb496994.aspx. 8. ^ https://mingw-w64.svn.sourceforge.net/svnroot/mingw-w64/experimental/winpthreads 9. ^ see http://locklessinc.com/articles/pthreads_on_windows which is where it was originally derived from
Further reading
David R. Butenhof. Programming with POSIX Threads. Addison-Wesley. ISBN 0-201-63392-2. Bradford Nichols, Dick Buttlar, Jacqueline Proulx Farell. Pthreads Programming. O'Reilly & Associates. ISBN 1-56592-115-1. Charles J. Northrup. Programming with UNIX Threads. John Wiley & Sons. ISBN 0-471-13751-0. Kay A. Robbins and Steven Robbins. UNIX Systems Programming. Prentice-Hall. ISBN 0-13042411-0.
External links
Pthreads Tutorial (https://computing.llnl.gov/tutorials/pthreads/) C/C++ Tutorial: using Pthreads (http://yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html) Article "POSIX threads explained (http://www-128.ibm.com/developerworks/linux/library/l-posix1.html) " by Daniel Robbins (Gentoo Linux founder) Interview "Ten Questions with David Butenhof about Parallel Programming and POSIX Threads
en.wikipedia.org/wiki/POSIX_Threads
(http://www.thinkingparallel.com/2007/04/11/ten-questions-with-david-butenhof-about-parallel-
3/4
11/28/12
(http://www.thinkingparallel.com/2007/04/11/ten-questions-with-david-butenhof-about-parallelprogramming-and-posix-threads/) " by Michael Suess Open Source POSIX Threads for Win32 (http://sources.redhat.com/pthreads-win32/) The Open Group Base Specifications Issue 6, IEEE Std 1003.1 (http://www.opengroup.org/onlinepubs/007904975/basedefs/pthread.h.html) Pthreads Presentation at 2007 OSCON (O'Reilly Open Source Convention) by Adrien Lamothe. An overview of Pthreads with current trends. (http://conferences.oreillynet.com/presentations/os2007/os_lamothe.pdf) Comparing programmability of Open MP and pthreads (http://www.futurechips.org/tips-for-powercoders/open-mp-pthreads.html) Retrieved from "http://en.wikipedia.org/w/index.php?title=POSIX_Threads&oldid=519372429" Categories: C POSIX library Parallel computing Threads (computing) This page was last modified on 23 October 2012 at 11:42. Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. See Terms of Use for details. Wikipedia is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.
en.wikipedia.org/wiki/POSIX_Threads
4/4