Chapter 4 - Threads Flashcards

1
Q

explain the difference between concurrency and parallelism

A

Concurrency exists when multiple threads are making progress, whereas parallelism exists when multiple threads are making progress simultaneously

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is data parallelism?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is task parallelism?

A

involves distributing tasks (threads) across multiple cores with each thread performing a unique operation. different threads maybe operating on the same or different data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what two types of threads are there?

A

user and kernel threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are the multithreading modes?

A

many to one, one to one, many to many

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the most common multithreading model?

A

one to one - used by modern OS’s. simplest to implement and also fully concurrent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are PThreads?

A

Posix Threads, the linux API for using threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is implicit threading?

A

the process of offloading thread management to compilers instead of the developer and using “tasks”, think tokio tasks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is a thread pool?

A

a way to limit the number of possible threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what benefits do thread pools have?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the fork join model?

A

a parent process spawning child threads and then waiting for those child threads to be done and joins those threads together to get results

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is OpenMP?

A

openmp provides compiler level directives and an API for programs written in C/C++ and Fortran to do parallel programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is grand central dispatch?

A

an apple technology for mac and ios. it’s a runtime library and an API for parallelization in a task model (implicit threading)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is Intel Thread Building Blocks

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what are the problems with fork() and exec() in terms of threading?

A

if someone calls fork() and spawns a separate duplicate process, do all the threads get copied?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is a signal?

A

notifies a process that a particular event has occurred. there are default signal handlers and user defined signal handlers

17
Q

what problem does thread-local storage solve?

A

it allows each thread to have it’s own copy of separate data if it needs it

18
Q

what is an upcall?

A

when the kernel needs to tell an application about certain events? it does this through the LWP

19
Q

what does linux consider both processes and threads as?

A

tasks

20
Q

what are the primary benefits of multithreading?

A

responsiveness, resource sharing, economy, scalability

21
Q

what are the two ways threads are terminated?

A

via asynchronous or deferred cancellation

22
Q
A