heavy weight, light weight
process creation is ____ ____ while thread creation is ____ ____
parallelism
implies a system can perform more than one task simultaneously
concurrency
supports more than one task making progress
data parallelism
distributes subsets of the same data across multiple cores, same operation on each
task parallelism
distributing threads across cores, each thread performing a unique operation
Amdahl’s Law
identifies performance gains from adding additional cores to an application that has both serial and parallel components
user threads
management done by user-level threads library
POSIX Pthreads
Windows threads
Java threads
enumerate the three primary thread libraries
kernel threads
threads which are supported by the kernel
many-to-one
is a multithreading model where user-level threads are mapped to a single kernel thread
many-to-one
is a multithreading model where one thread blocking causes all to be blocked.
many-to-one
is a multithreading model where multiple threads may not run in parallel on muticore system because only one may be in kernel at a time.
one-to-one
is a multithreading model where each user-level thread maps to a kernel thread
many-to-many
is a multithreading model that allows many user level threads to be mapped to many kernel threads
many-to-many
is a multithreading model that allows the operating system to create a sufficient number of kernel threads
two-level model
is a multithreading model that is similar to M:M, except that it allows a user thread to be bound to
kernel thread
thread library
provides programmer with API for creating and managing threads
library entirely in user space
kernel-level library supported by the OS
two main ways of implementing thread libraries
Pthreads
A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization. It be provided either as user-level or kernel-level.
implicit threading
Creation and management of threads done by compilers and run-time libraries rather than programmers
Thread Pools
Fork-Join
OpenMP
Grand Central Dispatch
Intel Threading Building Blocks
what are the five methods of implicit threading?
thread pools
An implicit threading method where a number of threads are created in a pool where they await work
Fork-Join Parallelism
An implicit threading method where multiple threads (task) are forked and then joined
Grand Central Dispatch
An implicit threading method that extends to C, C++ and Objective-C languages, API, and run-time
library.
It allows identification of parallel sections. It also manages most of the details of threading and puts blocks in “^{}”.
serial, main queue
____ is a type of dispatch queue where blocks are removed in FIFO order, queue is per process, called ___ ____
concurrent
is a type of dispatch queue where blocks are removed in FIFO order but several may be removed at a time
signals
are used in UNIX systems to notify a process that a particular event has occurred.
signal handler
is used to process signals
default handler
Every signal has ___ ____ that kernel runs when handling signal
user-defined
____ signal handler can override default
thread cancellation
Terminating a thread before it has finished
target thread
Thread to be canceled
Asynchronous cancellation
terminates the target thread immediately
Deferred cancellation
allows the target thread to periodically check if it should be cancelled. It is the default type of thread cancellation.
signals
On Linux systems, thread cancellation is handled through ___
interrupt()
Deferred cancellation uses the ____ method
Thread-local storage (TLS)
allows each thread to have its own copy of data
Thread-local storage (TLS)
Useful when you do not have control over the thread creation process
lightweight process (LWP)
An intermediate data structure between user and kernel threads
lightweight process (LWP)
Appears to be a virtual processor on which process can schedule user thread to run
upcalls
a communication mechanism, provided by scheduler activations, from the kernel to the upcall handler in the thread library
Windows API
primary API for Windows applications
context
The register set, stacks, and private storage area are known as the ___ of the thread
thread id
register set representing state of processor
separate user and kernel stacks for when thread runs in user mode or kernel mode
Private data storage area used by run-time libraries and dynamic link libraries (DLLs)
enumerate the components each windows thread has
ETHREAD (executive thread block)
a primary data structure of a Windows thread that includes pointer to process to which thread belongs and to KTHREAD, in kernel space
KTHREAD (kernel thread block)
a primary data structure of a Windows thread with scheduling and synchronization info, kernel-mode stack, pointer to TEB, in kernel space
TEB (thread environment block)
a primary data structure of a Windows thread with thread id, user-mode stack, thread-local storage, in user space
tasks
the Linux term for threads
clone()
system call to create a thread in Linux
struct task_struct
points to process data structures (shared or unique)
CLONE_FS
a Linux flag that indicates that File-system information is shared
CLONE_VM
a Linux flag that indicates that the same memory space is shared
CLONE_SIGHAND
a Linux flag that indicates that signal handlers are shared.
CLONE_FILES
a Linux flag that indicates that the set of open files is shared.