Chapter 4 - Threads Flashcards
explain the difference between concurrency and parallelism
Concurrency exists when multiple threads are making progress, whereas parallelism exists when multiple threads are making progress simultaneously
what is data parallelism?
focuses on distributing subsets of the same data across multiple computing cores and performing the same operation on each core. imagine multiple cores splitting up a large array to sum them
what is task parallelism?
involves distributing tasks (threads) across multiple cores with each thread performing a unique operation. different threads maybe operating on the same or different data
what two types of threads are there?
user and kernel threads
what are the multithreading modes?
many to one, one to one, many to many
what is the most common multithreading model?
one to one - used by modern OS’s. simplest to implement and also fully concurrent
what are PThreads?
Posix Threads, the linux API for using threads
what is implicit threading?
the process of offloading thread management to compilers instead of the developer and using “tasks”, think tokio tasks
what is a thread pool?
a way to limit the number of possible threads
what benefits do thread pools have?
using an existing thread is faster than new thread, separation of the thing that needs to be performed and the actual performing (leaves room for optimization)
what is the fork join model?
a parent process spawning child threads and then waiting for those child threads to be done and joins those threads together to get results
what is OpenMP?
openmp provides compiler level directives and an API for programs written in C/C++ and Fortran to do parallel programming
what is grand central dispatch?
an apple technology for mac and ios. it’s a runtime library and an API for parallelization in a task model (implicit threading)
what is Intel Thread Building Blocks
a template library that supports designing parallel applications in C++. it can be easily called to simply just pass some code to it and it’ll run it on a thread
what are the problems with fork() and exec() in terms of threading?
if someone calls fork() and spawns a separate duplicate process, do all the threads get copied?