Chapter 4 - Threads & Concurrency Flashcards

1
Q

What does a thread represent?

A

A thread represents a basic unit of CPU utilization, and threads belonging to the same process share many of the process resources, including code and data.

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

What are the four primary benefits to multithreaded applications?

A
  1. responsiveness
  2. resource sharing
  3. economy
  4. scalability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are concurrency and parallelism and when are they possible?

A

Concurrency exists when multiple threads are making progress, whereas parallelism exists when multiple threads are making progress simlutaneously. On a system with a single CPU, only concurrency is possible;

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

What does data parallelism distrubute?

A

Data parallelism distributes subsets of the same data across different computing cores and performs the same operation on each core. Task parallelism distrubtes not data but tasks across multiple cores. Each task is running a unique operation.

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

What creates user-level threads?

A

User applications create user-level threads, which must ultimately be mapped to kernel threads to execute on a CPU. The many-to-one model maps many user-level threads to one kernel thread. Other approaches include the one-to-one and many-to-many models.

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

What does a thread library provide?

A

A thread library provides an API for creating and managing threads. Three common thread libraries include Windows, Pthreads, and Java threading. Windows is for the Windows system only, while Pthreads is available for POSIX-compatible systems such as UNIX, Linux, and macOS. Java threads will run on any system that supports a Java virtual machine.

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

What does implicit threading involve?

A

Implicit threading involves identifying tasks – not threads – and allowing languages or API frameworks to create and manage threads. There are several approaches to implicit threading, including thread pools, fork-join frameworks, and Grand Central Dispatch.

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

How can threads be terminated?

A

Threads may be terminated using either asynchronous or deferred cancellation. Asynchronous cancellation stops a thread immediately, even if it is in the middle of performing an update. Deferred cancellation informs a thread that it should terminate but allows the thread to terminate in an orderly fashion. In most circumstances, deferred cancellation is preferred to asynchronous termination.

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

How are processes and threads referred to in Linux?

A

Unlike many other operating systems, Linux does not distinguish between processes and threads; instead, it refers to each as a task. The linux clone() system call can be used to create tasks that behave either more like processes or more like threads.

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