Thread (computing): Difference between revisions

Content deleted Content added
Kernel threads: That just links back here.
m Small changes for readability, last paragraph. Rewording blurb about Python's GIL. Punctuation.
Line 127:
* Many implementations of [[C (programming language)|C]] and [[C++]] support threading, and provide access to the native threading APIs of the operating system. A standardized interface for thread implementation is [[POSIX Threads]] (Pthreads), which is a set of C-function library calls. OS vendors are free to implement the interface as desired, but the application developer should be able to use the same interface across multiple platforms. Most [[Unix]] platforms, including Linux, support Pthreads. Microsoft Windows has its own set of thread functions in the [[process.h]] interface for multithreading, like [[beginthread]].
* Some [[high-level programming language|higher level]] (and usually [[cross-platform]]) programming languages, such as [[Java (programming language)|Java]], [[Python (programming language)|Python]], and [[.NET Framework]] languages, expose threading to developers while abstracting the platform specific differences in threading implementations in the runtime. Several other programming languages and language extensions also try to abstract the concept of concurrency and threading from the developer fully ([[Cilk]], [[OpenMP]], [[Message Passing Interface]] (MPI)). Some languages are designed for sequential parallelism instead (especially using GPUs), without requiring concurrency or threads ([[Ateji PX]], [[CUDA]]).
* A few interpreted programming languages have implementations (e.g., [[Ruby MRI]] for Ruby, [[CPython]] for Python) which support threading and concurrency but not parallel execution of threads, due to a [[global interpreter lock]] (GIL). The GIL is a mutual exclusion lock held by the interpreter that can prevent the interpreter from simultaneously interpreting the applicationsapplication's code on two or more threads at once,. whichThis effectively limits the parallelism on multiple core systems. ThisIt also limits performance mostly for processor-bound threads, (which require the processor), andbut notdoesn't much foreffect I/O-bound or network-bound ones as much. Other implementations of interpreted programming languages, such as [[Tcl]] using the Thread extension, avoid the GIL limit by using an Apartment model where data and code must be explicitly "shared" between threads. In Tcl each thread has one or more interpreters.
* In programming models such as [[CUDA]] designed for [[data parallel computation]], an array of threads run [[compute kernel|the same code]] in parallel using only its ID to find its data in memory. In essence, the application must be designed so that each thread performs the same operation on different segments of memory so that they can operate in parallel and use the GPU architecture.
* [[Hardware description language]]s such as [[Verilog]] have a different threading model that supports extremely large numbers of threads (for modeling hardware).