FACTOID # 4: China's labor force stands at 706 million people, almost three times that of Europe and twice that of North and South America combined
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Thread (computer science)
A process with two threads of execution.
A process with two threads of execution.

A thread in computer science is short for a thread of execution. Threads are a way for a program to fork (or split) itself into two or more simultaneously (or pseudo-simultaneously) running tasks. Threads and processes differ from one operating system to another, but in general, the way that a thread is created and shares its resources is different from the way a process does. In computer science, a subroutine (function, method, procedure, or subprogram) is a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code. ... In computer science, the term threaded code refers to an implementation technique for programming languages that produces very compact code. ... Image File history File links This is a lossless scalable vector image. ... Image File history File links This is a lossless scalable vector image. ... Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ... A computer program is a collection of instructions that describe a task, or set of tasks, to be carried out by a computer. ... A fork, when applied to computing is when a process creates a copy of itself, which then acts as a child of the original process, now called the parent. More generally, a fork in a multithreading environment means that a thread of execution is duplicated. ... A task is an execution path through address space. In other words, a set of program instructions that is loaded in memory. ... In computing, a process is an instance of a computer program that is being executed. ... It has been suggested that Maintenance OS be merged into this article or section. ... In computing, a process is an instance of a computer program that is being executed. ...


Multiple threads can be executed in parallel on many computer systems. This multithreading generally occurs by time slicing (similar to time-division multiplexing), wherein a single processor switches between different threads, in which case the processing is not literally simultaneous, for the single processor is really doing only one thing at a time. This switching can happen so fast as to give the illusion of simultaneity to an end user. For instance, most PCs today only contain one processor core, but you can run multiple programs at once, such as typing in a document editor while listening to music in an audio playback program; though the user experiences these things as simultaneous, in truth, the processor quickly switches back and forth between these separate processes. On a multiprocessor or multi-core system, now coming into general use, threading can be achieved via multiprocessing, wherein different threads and processes can run literally simultaneously on different processors or cores. In computing, multitasking is a method by which multiple tasks, also known as processes, share common processing resources such as a CPU. In the case of a computer with a single CPU, only one task is said to be running at any point in time, meaning that the CPU is... Time-division multiplexing (TDM) is a type of digital or (rarely) analog multiplexing in which two or more signals or bit streams are transferred apparently simultaneously as sub-channels in one communication channel, but physically are taking turns on the channel. ... Die of an Intel 80486DX2 microprocessor (actual size: 12×6. ... A context switch is the computing process of storing and restoring the state (context) of a CPU such that multiple processes can share a single CPU resource. ... This article does not cite any references or sources. ... Multiprocessing is traditionally known as the use of multiple concurrent processes in a system as opposed to a single process at any one instant. ...


Many modern operating systems directly support both time-sliced and multiprocessor threading with a process scheduler. The operating system kernel allows programmers to manipulate threads via the system call interface. Some implementations are called a kernel thread, whereas a lightweight process is a specific type of kernel thread that shares the same state and information. It has been suggested that Maintenance OS be merged into this article or section. ... Scheduling is a key concept in computer multitasking and multiprocessing operating system design, and in real-time operating system design. ... A kernel connects the application software to the hardware of a computer. ... In computing, a system call is the mechanism used by an application program to request service from the operating system. ... A light-weight process (LWP), also known as kernel thread, is a schedulable entity that the kernel is aware of. ...


Absent that, programs can still implement threading by using timers, signals, or other methods to interrupt their own execution and hence perform a sort of ad hoc time-slicing. These are sometimes called user-space threads.

Contents

Threads compared with processes

Threads are distinguished from traditional multitasking operating system processes in that processes are typically independent, carry considerable state information, have separate address spaces, and interact only through system-provided inter-process communication mechanisms. Multiple threads, on the other hand, typically share the state information of a single process, and share memory and other resources directly. Context switching between threads in the same process is typically faster than context switching between processes. Systems like Windows NT and OS/2 are said to have "cheap" threads and "expensive" processes; in other operating systems there is not so great a difference. In computing, multitasking is a method by which multiple tasks, also known as processes, share common processing resources such as a CPU. In the case of a computer with a single CPU, only one task is said to be running at any point in time, meaning that the CPU is... In computing, a process is, roughly speaking, a task being run by a computer, often simultaneously with many other tasks. ... In information processing, a state is the complete set of properties (for example, its energy level, etc. ... The introduction to this article provides insufficient context for those unfamiliar with the subject matter. ... Inter-Process Communication (IPC) is a set of techniques for the exchange of data between two or more threads in one or more processes. ... This article or section does not cite any references or sources. ... A resource, also referred to as system resource, is any physical or virtual system component of a computer system with limited availability. ... A context switch is the computing process of storing and restoring the state of a CPU (the context) such that multiple processes can share a single CPU resource. ... Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. ... To meet Wikipedias quality standards, this article or section may require cleanup. ...


Multithreading is a popular programming and execution model that allows multiple threads to exist within the context of a single process, sharing the process' resources but able to execute independently. The threaded programming model provides developers with a useful abstraction of concurrent execution. However, perhaps the most interesting application of the technology is when it is applied to a single process to enable parallel execution on a multiprocessor system.


This advantage of a multithreaded program allows it to operate faster on computer systems that have multiple CPUs, CPUs with multiple cores, or across a cluster of machines. This is because the threads of the program naturally lend themselves to truly concurrent execution. In such a case, the programmer needs to be careful to avoid race conditions, 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 operations (often implemented using semaphores) in order to prevent common data from being simultaneously modified, or read while in the process of being modified. Careless use of such primitives can lead to deadlocks. To meet Wikipedias quality standards, this article may require cleanup. ... Die of an Intel 80486DX2 microprocessor (actual size: 12×6. ... An example of a Computer cluster A computer cluster is a group of tightly coupled computers that work together closely so that in many respects they can be viewed as though they are a single computer. ... The Dining Philosophers, a classic problem involving concurrency and shared resources In computer science, concurrency is a property of systems in which several computational processes are executing at the same time, and potentially interacting with each other. ... A programmer or software developer is someone who programs computers, that is, one who writes computer software. ... A race condition or race hazard is a flaw in a system or process whereby the output of the process is unexpectedly and critically dependent on the sequence or timing of other events. ... The rendezvous dilemma is related to the prisoners dilemma and can be formulated in this way: Two young people have a date in a park they have never been to before. ... ... A semaphore is a protected variable (or abstract data type) and constitutes the classic method for restricting access to shared resources (e. ... It has been suggested that Circular wait be merged into this article or section. ...


Operating systems schedule threads in one of two ways. Preemptive multithreading is generally considered the superior approach, 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. This can create problems if a thread is waiting for a resource to become available. The disadvantage to preemptive multithreading is that the system may make a context switch at an inappropriate time, causing priority inversion or other bad effects which may be avoided by cooperative multithreading. A context switch is the computing process of storing and restoring the state (context) of a CPU such that multiple processes can share a single CPU resource. ... In scheduling, priority inversion is the inverting the relative priorities of the two tasks. ...


Traditional mainstream computing hardware did not have much support for multithreading as switching between threads was generally already quicker than full process context switches. Processors in embedded systems, which have higher requirements for real-time behaviors, might support multithreading by decreasing the thread switch time, perhaps by allocating a dedicated register file for each thread instead of saving/restoring a common register file. In the late 1990s, the idea of executing instructions from multiple threads simultaneously has become known as simultaneous multithreading. This feature was introduced in Intel's Pentium 4 processor, with the name Hyper-threading. A context switch is the computing process of storing and restoring the state (context) of a CPU such that multiple processes can share a single CPU resource. ... What is an Embedded System? Electronic devices that incorporate a computer(usually a microprocessor) within their implementation. ... For the band, see 1990s (band). ... Simultaneous multithreading, often abbreviated as SMT, is a technique for improving the overall efficiency of the hardware that executes instructions in a computer. ... Intel Corporation (NASDAQ: INTC, SEHK: 4335), founded in 1968 as Integrated Electronics Corporation, is an American multinational corporation that is best known for designing and manufacturing microprocessors and specialized integrated circuits. ... The Pentium 4 brand refers - since 2000 - to Intels mainstream desktop and mobile single-core CPUs with the seventh-generation NetBurst architecture, which was the companys first all-new design since the Intel P6 of the Pentium Pro branded CPUs of 1995. ... Hyper-Threading (HTT = Hyper Threading Technology) is Intels trademark for their implementation of the simultaneous multithreading technology on the Pentium 4 microarchitecture. ...


Processes, threads, and fibers

A process is the "heaviest" unit of kernel scheduling. Processes own resources allocated by the operating system. Resources include memory, file handles, sockets, device handles, and windows. Processes do not share address spaces or file resources except through explicit methods such as inheriting file handles or shared memory segments, or mapping the same file in a shared way. Processes are typically pre-emptively multitasked. However, Windows 3.1 and older versions of Mac OS used co-operative or non-preemptive multitasking. In computing, a process is an instance of a computer program that is being executed. ... A fiber in computer science is a term for a particularly lightweight thread of execution. ... A resource, also referred to as system resource, is any physical or virtual system component of a computer system with limited availability. ...


A thread is the "lightest" unit of kernel scheduling. At least one thread exists within each process. If multiple threads can exist within a process, then they share the same memory and file resources. Threads are pre-emptively multitasked if the operating system's process scheduler is pre-emptive. Threads do not own resources except for a stack and a copy of the registers including the program counter. In computer science, a call stack is a special stack which stores information about the active subroutines of a computer program. ... In computer architecture, a processor register is a small amount of very fast computer memory used to speed the execution of computer programs by providing quick access to commonly used values—typically, the values being in the midst of a calculation at a given point in time. ... The program counter (also called the instruction pointer in some computers) is a register in a computer processor which indicates where the computer is in its instruction sequence. ...


In some situations, there is a distinction between "kernel threads" and "user threads" -- the former are managed and scheduled by the kernel, whereas the latter are managed and scheduled in userspace. In this article, the term "thread" is used to refer to kernel threads, whereas "fiber" is used to refer to user threads. Fibers are co-operatively scheduled: a running fiber must explicitly "yield" to allow another fiber to run. A fiber can be scheduled to run in any thread in the same process. An operating system usually segregates the available system memory into kernel space and user space. ... It has been suggested that this article or section be merged into Computer_multitasking#Cooperative_multitasking. ...


Thread and fiber issues

Concurrency and data structures

Threads in the same process share the same address space. This allows concurrently-running code to couple tightly and conveniently exchange data without the overhead or complexity of an IPC. When shared between threads, however, even simple data structures become prone to race hazards if they require more than one CPU instruction to update: two threads may end up attempting to update the data structure at the same time and find it unexpectedly changing underfoot. Bugs caused by race hazards can be very difficult to reproduce and isolate. In computer science, coupling or dependency is the degree to which each program module relies on each other module. ... Inter-Process Communication (IPC) is a set of techniques for the exchange of data between two or more threads in one or more processes. ... A race condition or race hazard is a flaw in a system or process whereby the output of the process is unexpectedly and critically dependent on the sequence or timing of other events. ...


To prevent this, threading APIs offer synchronization primitives such as mutexes to lock data structures against concurrent access. On uniprocessor systems, a thread running into a locked mutex must sleep and hence trigger a context switch. On multi-processor systems, the thread may instead poll the mutex in a spinlock. Both of these may sap performance and force processors in SMP systems to contend for the memory bus, especially if the granularity of the locking is fine. Mutual exclusion (often abbreviated to mutex) algorithms are used in concurrent programming to avoid the simultaneous use of un-shareable resources by pieces of computer code called critical sections. ... In computer science, a lock is a synchronization mechanism for enforcing limits on access to a resource in an environment where there are many threads of execution. ... In software engineering, a spinlock is a lock where the thread simply waits in a loop (spins) repeatedly checking until the lock becomes available. ... Granularity is a measure of the size of the components, or descriptions of components, that make up a system. ...


I/O and scheduling

Many fiber implementations are entirely in userspace. As a result, context switching between fibers within the same process is extremely efficient because it does not require any interaction with the kernel at all: a context switch can be performed by locally saving the CPU registers used by the currently executing fiber and then loading the registers required by the fiber to be executed. Since scheduling occurs in userspace, the scheduling policy can be more easily tailored to the requirements of the program's workload. An operating system usually segregates the available system memory into kernel space and user space. ...


However, the use of blocking system calls in fibers can be problematic. If a fiber performs a system call that blocks, the other fibers in the process are unable to run until the system call returns. A typical example of this problem is when performing I/O: most programs are written to perform I/O synchronously. When an I/O operation is initiated, a system call is made, and does not return until the I/O operation has been completed. In the intervening period, the entire process is "blocked" by the kernel and cannot run, which starves other fibers in the same process from executing.


A common solution to this problem is providing an I/O API that implements a synchronous interface by using non-blocking I/O internally, and scheduling another fiber while the I/O operation is in progress. Similar solutions can be provided for other blocking system calls. Alternatively, the program can be written to avoid the use of synchronous I/O or other blocking system calls.


Win32 supplies a fiber API. SunOS 4.x implemented "light-weight processes" or LWPs as fibers known as green threads. SunOS 5.x and later, NetBSD 2.x, and DragonFly BSD implement LWPs as threads as well. A thread in computer science is short for a thread of execution. ... SunOS was the version of the UNIX operating system developed by Sun Microsystems for their workstations and server systems until the early 1990s. ... NetBSD is a freely redistributable, open source version of the Unix-like BSD computer operating system. ... DragonFly BSD is a free, Unix-like operating system which was forked from FreeBSD 4. ...


The use of kernel threads simplifies user code by moving some of the most complex aspects of threading into the kernel. The program doesn't need to schedule threads or explicitly yield the processor. User code can be written in a familiar procedural style, including calls to blocking APIs, without starving other threads. However, kernel threading on uniprocessor systems may force a context switch between threads at any time, and thus expose race hazards and concurrency bugs that would otherwise lie latent. On SMP systems, this is further exacerbated because kernel threads may actually execute concurrently on separate processors.


Implementations

There are many different and incompatible implementations of threading. These include both kernel-level and user-level implementations.


Note that fibers can be implemented without operating system support, although some operating systems or libraries provide explicit support for them. For example, Microsoft Windows (Windows NT 3.51 SP3 and later) support a fiber API for applications that want to gain performance improvements by managing scheduling themselves, instead of relying on the kernel scheduler (which may not be tuned for the application). Microsoft SQL Server 2000's user mode scheduler, running in fiber mode, is an example of doing this.


Kernel-level implementation examples

Light Weight Kernel Threads or LWKT is a term from computer science in general and in DragonFly BSD in particular. ... In the Linux operating system, the Native POSIX Thread Library (NPTL) is a software feature that enables the Linux kernel to run programs written to use POSIX Threads very efficiently. ... Linux (IPA pronunciation: ) is a Unix-like computer operating system. ... POSIX Threads is a POSIX standard for threads. ... In computer science, a nanokernel or picokernel is a very minimalist operating system kernel. ... Mac OS 8 is a series of versions of the Mac OS that supported a transition through major changes in the Macintosh hardware platform. ...

User-level implementation examples

GNU Pth (Portable Threads) is a POSIX/ANSI-C based thread library which provides priority-based scheduling for multithreading applications. ... FSU Threads were developed by Ted Baker and his computer science students at Florida State University for use in the Ada programming language. ... Apple Inc. ... REALbasic (RB) is an object-oriented dialect of the BASIC programming language developed and commercially marketed by REAL Software, Inc in Austin, Texas for Mac OS X, Microsoft Windows, and Linux. ... The Netscape Portable Runtime, or NSPR, is a platform abstraction library that makes all operating systems it supports appear the same to Mozilla. ...

Hybrid implementation examples

  • Scheduler activations used by the NetBSD native POSIX threads library implementation (an N:M model as opposed to a 1:1 kernel or userspace implementation model)

Scheduler Activations is a threading mechanism that, when implemented in an operating systems process scheduler, provides kernel-level thread functionality with user-level thread flexibility and performance. ...

See also

Multithreading computers have hardware support to efficiently execute multiple threads. ... This article does not cite any references or sources. ... Simultaneous multithreading, often abbreviated as SMT, is a technique for improving the overall efficiency of the hardware that executes instructions in a computer. ... In computer science, Communicating Sequential Processes (CSP) is a formal language for describing patterns of interaction in concurrent systems. ... In computing, multitasking is a method by which multiple tasks, also known as processes, share common processing resources such as a CPU. In the case of a computer with a single CPU, only one task is said to be running at any point in time, meaning that the CPU is... In computer science, message passing is a form of communication used in concurrent programming, parallel programming, object-oriented programming, and interprocess communication. ... Thread-safety is a computer programming concept applicable to multi-threaded programs. ... In scheduling, priority inversion is the inverting the relative priorities of the two tasks. ... In Computer Science, protothreads are a low-overhead mechanism for concurrent programming. ... In the thread pool pattern in programming, a number of N threads are created to perform a number of M tasks, usually organized in a queue. ... In contrast to algorithms that protect access to shared data with locks, lock-free and wait-free algorithms are specially designed to allow multiple threads to read and write shared data concurrently without corrupting it. ...

References

  • 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
  • Mark Walmsley: Multi-Threaded Programming in C++, Springer, ISBN 1-85233-146-1
  • Paul Hyde: Java Thread Programming, Sams, ISBN 0-672-31585-8
  • Bill Lewis: Threads Primer: A Guide to Multithreaded Programming, Prentice Hall, ISBN 0-13-443698-9
  • Steve Kleiman, Devang Shah, Bart Smaalders: Programming With Threads, SunSoft Press, ISBN 0-13-172389-8
  • Pat Villani: Advanced WIN32 Programming: Files, Threads, and Process Synchronization, Harpercollins Publishers, ISBN 0-87930-563-0
  • Jim Beveridge, Robert Wiener: Multithreading Applications in Win32, Addison-Wesley, ISBN 0-201-44234-5
  • Thuan Q. Pham, Pankaj K. Garg: Multithreaded Programming with Windows NT, Prentice Hall, ISBN 0-13-120643-5
  • Len Dorfman, Marc J. Neuberger: Effective Multithreading in OS/2, McGraw-Hill Osborne Media, ISBN 0-07-017841-0
  • Alan Burns, Andy Wellings: Concurrency in ADA, Cambridge University Press, ISBN 0-521-62911-X
  • Uresh Vahalia: Unix Internals: the New Frontiers, Prentice Hall, ISBN 0-13-101908-2
  • Alan L. Dennis: .Net Multithreading , Manning Publications Company, ISBN 1-930110-54-5
  • Tobin Titus, Fabio Claudio Ferracchiati, Srinivasa Sivakumar, Tejaswi Redkar, Sandra Gopikrishna: C# Threading Handbook, Peer Information Inc, ISBN 1-86100-829-5
  • Tobin Titus, Fabio Claudio Ferracchiati, Srinivasa Sivakumar, Tejaswi Redkar, Sandra Gopikrishna: Visual Basic .Net Threading Handbook, Wrox Press Inc, ISBN 1-86100-713-2

Professor Alan Burns (currently beardless) Professor Alan Burns is currently the head of the University of York Computer Science Department. ... Andy Wellings is a professor in the Computer Science department at the University of York in northern England. ...

External links

Topics in Parallel Computing  v  d  e 
General High-performance computing
Parallelism Data parallelismTask parallelism
Theory SpeedupAmdahl's lawFlynn's Taxonomy (SISD, SIMD, MISD, MIMD) • Cost efficiencyGustafson's Law • Karp-Flatt metric
Elements ProcessThreadFiberParallel Random Access Machine
Coordination MultiprocessingMultithreadingMultitaskingMemory coherencyCache coherencyBarrierSynchronizationDistributed computingGrid computing
Programming Programming modelImplicit parallelismExplicit parallelism
Hardware Computer clusterBeowulfSymmetric multiprocessing • Non-Uniform Memory Access • Cache only memory architectureAsymmetric multiprocessingSimultaneous multithreadingShared memoryDistributed memoryMassively parallel processingSuperscalar processingVector processingSupercomputerStream processing
Software Distributed shared memoryApplication checkpointingWareWulf
APIs PthreadsOpenMPMessage Passing Interface (MPI)
Problems Embarrassingly parallelGrand Challenge • Software lockout

  Results from FactBites:
 
Thread (computer science) - Wikipedia, the free encyclopedia (2665 words)
A thread in computer science is short for a thread of execution.
The distinctions between threads and processes differ from one operating system to another, but in general, the way that a thread is created and shares its resources is different from the way a process does.
Threads are distinguished from traditional multi-tasking operating system processes in that processes are typically independent, carry considerable state information, have separate address spaces, and interact only through system-provided inter-process communication mechanisms.
Thread (computer science) (346 words)
Threads are similar to processes, in that both represent a single sequence of instructions executed in parallel with sequences, either by time slicing[?] or multiprocessing.
Threads are distinguished from traditional multi-tasking processes in that processes are typically independent, carry considerable state information, and interact only through system-provided inter-process communication mechanisms.
Threads may also require atomic operations (often implemented using semaphores) in order to prevent data from being simultaneously modified, or read while in the process of being modified.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.