Thread (computing): Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 10:
Systems like [[Windows NT]] and [[OS/2]] are said to have "cheap" threads and "expensive" processes, while in systems like [[Linux]] there is not so big a difference.
 
An advantage of a multi-threaded program is that it can operate faster on [[computer system]]s that have multiple [[CPU]]s, or across a [[computer cluster|cluster]] of machines. This is because the threads of the program naturally lend themselves for truly [[concurrent programming|concurrent]] [[execution (computers)|execution]]. In such a case, the [[programmer]] needs to be careful to avoid [[race condition]]s, and other non-intuitive behaviors. In order for data to be correctly manipulated, threads will often need to [[rendezvous]] in time in order to process the data in the correct order. Threads may also require [[Atomic_(computer_science)|atomic]] operations (often implemented using [[semaphore (programming)|semaphores]]) in order to prevent common data from being simultaneously modified, or read while in the process of being modified. Careless use of such [[primitive]]s can lead to [[deadlock]]s.
 
Use of threads in [[programming]] often causes a [[state inconsistency]]. A common [[anti-pattern]] is to set a [[global variable]], then invoke [[subprogram]]s that depend on its value. This is known as [[accumulate and fire]].
fire]].
 
Operating systems generally implement threads in either of two ways: [[preemptive multithreading]], or [[cooperative multithreading]]. Preemptive multithreading is the superior implementation, as it allows the operating system to determine when a [[context switch]] should occur. Cooperative multithreading on the other hand, relies on the threads themselves to relinquish control once they are at a stopping point. Clearly this can create problems if a thread is waiting for a resource to become available.
 
The [[Java programming language]] is an example of a [[computer language]] which supports multi-threaded [[computer program|program]]s.
 
Hardware support for software threads is provided by [[simultaneous multithreading]]. This feature was introduced in [[Intel]]'s [[Pentium 4]] processor, with the name ''[[Hyper-threading]]''.
 
==[[Programming tool]]s==
*[[Apache Portable Runtime]] (APR)
*[[Boost Threads]]
*[[BSP-Library]]
*[[Cheap Threads]]
*[[Common Cpp|Common C++]]
*[[Cpp Portable Types Library|C++ Portable Types Library]]
*[[Cpp Threads|C++ Threads]]
*[[GNU Portable Threads library]] (Pth)
*[[JThreads-Cpp|JThreads/C++]]
*[[Liboop]]
*[[Libthreadedserver]]
*[[Multithreaded Server Class]]
*[[netthreadedserver]]
*[[OpenThreads]]
*[[OpenTop]]
*[[pthread]]
*[[RTpp|RT++]]
*[[SafePt]]
*[[TThread]]
*[[Weftspp|Wefts++]]
*[[Win32]]
*[[Wonderlib]]
*[[ZThreads]]
 
==See also==
* [[Thread-safety|Thread safety]]
* [[Threading model]]
* [[green threads]]
* [[socket]]s
* [[server]]s
* [[worker]]
* [[communication]]
* [[signal]]s
* [[completion port]]
* [[synchronization]]
* [[priority inversion]]
* [[Occam programming language|Occam]]
* [[SR language]]
* [[OpenMP]]
* [[CORBA]]
* [[.NET]]
* [[DotGNU Execution Environment]]
* [[ProActive]]
* [[Adaptive Communication Environment]] (ACE™)
* [[clone (function)|clone()]]
* [[fork (function)|fork()]]
* [[Lock-free and wait-free algorithms]]
* [[Communicating sequential processes]]
* [[Message passing]]
* [[Microkernel]]
----
 
An unrelated use of the term '''thread''' is for [[threaded code]], which is a form of code consisting entirely of [[subroutine]] calls, written without the subroutine call instruction, and processed by an [[interpreter (computing)|interpreter]] or the CPU. Two threaded code languages are [[Forth programming language|Forth]] and early [[B programming language]]s.
 
== External links ==
* [http://arstechnica.com/paedia/h/hyperthreading/hyperthreading-1.html Ars Technica article about multithreading, etc]
* [http://www.ece.utexas.edu/~valvano/EE345M/view04.pdf Page 1] & [http://www.ece.utexas.edu/~valvano/EE345M/view05.pdf Page 2], a preemptive multithreaded implementation described
* [news:comp.programming.threads Forum]
* [http://www.lambdacs.com/cpt/FAQ.html Frequently Asked Questions], [http://www.lambdacs.com/cpt/MFAQ.html Most FAQ]
* [http://groups.google.com/groups?group=comp.programming.threads&threadm=580fae16.0312210310.1410bf2b%40posting.google.com Discussion "Writing a scalable server"]
Line 47 ⟶ 85:
* [http://www.cs.rice.edu/CS/Systems/ScalaServer/ System support for scalable network servers]
* [http://citeseer.nj.nec.com/larus02using.html cohort scheduling]
* Survey "[http://www.audiomulch.com/~rossb/code/lockfree/ Some Notes on Lock-Free and Wait-Free Algorithms]" by [[Ross Bencina]]