1 Glossary
(adopted from the description of the RogueWave Threads.h++ package)
- Process
- A process is a program that is loaded into memory and prepared for execution. Each
process has a private address space. Processes begin with a single thread.
- Thread
- A thread of control, or more simply, a thread, is a sequence of instructions being
executed in a program. A thread has a program counter and a private stack to keep track of
local variables and return addresses. A multithreaded process is associated with one or
more threads. Threads execute independently. All threads in a given process share the
private address space of that process.
- Concurrency
- Concurrency exists when at least two threads are in progress at the same time. A system
with only a single processor can support concurrency by switching execution contexts among
multiple threads.
- Parallelism
- Parallelism arises when at least two threads are executing simultaneously. This requires
a system with multiple processors. Parallelism implies concurrency, but not vice-versa.
- Reentrant
- A function is reentrant if it will behave correctly even if a thread of execution enters
the function while one or more threads are already executing within the function. These
could be either the same thread, in the case of recursion, or different threads, in the
case of concurrency.
- Thread-specific data
- Thread-specific data (TSD) is also known as thread-local storage (TLS). Normally, any
data that has lifetime beyond the local variables on the thread's private stack are shared
among all threads within the process. Thread-specific data is a form of static or global
data that is maintained on a per-thread basis. That is, each thread gets its own private
copy of the data.
- Synchronization
- Left to their own devices, threads execute independently. Synchronization is the work
that must be done when there are, in fact, interdependencies that require some form of
communication among threads. Synchronization tools include mutexes, semaphores, condition
variables, and other variations on locking.
- Critical Section
- A critical section is a section of code that accesses a non-sharable resource. To ensure
correct code, only one thread at a time may execute in a critical section. In other words,
it is a section of code which is not reentrant.
- Mutex
- A mutex, or mutual exclusion lock, is a synchronization object with two states locked
and unlocked. A mutex is usually used to ensure that only one thread at a time executes
some critical section of code. Before entering a critical section a thread will attempt to
lock the mutex which guards that section. If the mutex is already locked, the thread will
block until the mutex is unlocked, at which time it will lock the mutex, execute the
critical section, and unlock the mutex upon leaving the critical section.
- Semaphore
- A semaphore is a synchronization mechanism that starts out initialized to some positive
value. A thread may ask to wait on a semaphore in which case the thread blocks until the
value of the semaphore is positive. At that time the semaphore count is decremented and
the thread continues. When a thread releases semaphore, the semaphore count is
incremented. Counting semaphores are useful for coordinating access to a limited pool of
some resource.
- Readers/Writer Lock
- A multiple-readers, single-writer lock is one that allows simultaneous read access by
many threads while restricting write access to only one thread at a time. When any thread
holds the lock for reading, other threads can also acquire the lock reading. If one thread
holds the lock for writing, or is waiting to acquire the lock for writing, other threads
must wait to acquire the lock for either reading or writing.
- Condition Variable
- Use a condition variables in conjunction with a mutex lock to automatically block
threads until a particular condition is true.
- Multithread safe levels
- A possible classification scheme to describe thread-safety of libraries:
- All public and protected functions are reentrant. The library provides protection
against multiple threads trying to modify static and global data used within a library.
The developer must explicitly lock access to objects shared between threads. No other
thread can write to a locked object unless it is unlocked. The developer needs to lock
local objects. The spirit, if not the letter, of this definition requires the user of the
library only to be familiar with the semantic content of the objects in use. Locking
access to objects that are being shared due to extra-semantic details of implementation
(for example, copy-on-write) should remain the responsibility of the library.
- All public and protected functions are reentrant. The library provides protection
against multiple threads trying to modify static and global data used within the library.
The preferred way of providing this protection is to use mutex locks. The library also
locks an object before writing to it. The developer is not required to explicitly lock or
unlock a class object (static, global or local) to perform a single operation on the
object. Note that even multithread safe level II hardly relieves the user of the library
from the burden of locking.
- Deadlock
- A thread suffers from deadlock if it is blocked waiting for a condition that will never
occur. Typically, this occurs when one thread needs to access a resource that is already
locked by another thread, and that other thread is trying to access a resource that has
already been locked by the first thread. In this situation, neither thread is able to
progress; they are deadlocked.
- Multiprocessor
- A hardware system with multiple processors or multiple, simultaneous execution units.
File translated from TEX by TTH,
version 2.30.
On 18 Apr 2000, 14:42.