The Java Fork-Join Pool: A Computation Model for Parallelism Flashcards

1
Q

The _ in Java provides a powerful and efficient mechanism for parallelizing tasks, particularly those amenable to the “divide and conquer” approach.

A

Fork-Join framework

Its internal workings are designed to maximize performance and scalability by leveraging multi-core processors and a sophisticated work-stealing algorithm.

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

The fork-join pool supports a style of parallel programming that solves problems by _.

Solve (problem)
—if problem is small enough
——solve problem directly (sequential algorithm)
—else
——split problem into independent parts
——fork new sub-tasks to solve each part
——join all sub-tasks
——compose result from sub-results

A

divide and conquer

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

Java Fork-Join Pool Computation Model
1. Splitting a task into sub-tasks creates the tasks by using the fork()ing
2. Solving the sub-tasks in parallel
▪ Implemented by fork-join framework
▪ Java execution environment,
▪ Operating System
▪ Hardware
▪ Subtask can run parallel on different cores
▪ can run concurrently in different threads on a single-core
3. Waiting for them to complete
4. Merging the results can use calls to join() to merge all sub-task results together

A

Noted

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

_ implements an Executor Service.

A

Fork-Join Pool

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

_ is the basis for Java Executor framework subclasses.

A

Executor Service

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

_ is the other implementation of ExecutorService executes in runnable or callable.

A

AbstractExecutorService

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

The purpose of ForkJoinPool in contrast, is to
execute _.

A

ForkJoinTasks

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

Each _ has its own stack, registers, etc.

A

worker thread

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

Fork() does not run the task immediately, but instead places it on the _.

A

work queue

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

Unlike thread.join(), ForkJoinTasks.join() doesn’t simply _ the calling thread. It uses _ to thread to run tasks.

A

block, workers

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

When a worker thread encounters a _, it processes other tasks until it notices that target sub-task is done.

A

join()

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

Programs rarely use the ForkJoinTask class directly, but instead, extend one of its subclasses & override compute() Three Classes:
* RecursiveAction – used for computations that do not return results
* RecursiveTask – used for computations that do return results
* CountedCompleter – used for computations in which completed actions trigger other actions

A

Noted

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

ForkJoinPool enables a _ client to process ForkJoinTasks

A

non-ForkJoinTask

The client inserts new tasks onto a shared queue used to fee “work stealing queues managed by worker threads.

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

The goal of “work-stealing” is to maximize _.

A

processor core utilization

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

Each worker thread in a forkjoinpool runs in a _ that scans from sub-tasks to execute.

A

loop

  • The goal for the work thread is to keep as busy as possible.
  • The worker threads only block waiting for work if no (sub-) tasks are available to run therefore, the working thread checks multi-input sources for (sub-) tasks to execute.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The Fork-Join Framework Internal

If the tasks run by a worker thread call fork(), the new tasks is pushed on the _ of the worker’s deque. The way this works is that a worker thread processes the elements on its deque in LIFO order.

A

head

It then pops (sub-)tasks from the head of its deque and runs them to completion.

17
Q

The WorkQueue deque that implements workstealing minimizes _.

A

locking contention

18
Q

CONCLUSION:

The fork-join Pool computation model is a valuable tool for parallelizing tasks, particularly those that can be divided into independent subtasks the Fork-Join framework’s internal workings are carefully designed to maximize performance and scalability in parallel programming. Its work-stealing algorithm, efficient task management, and high-level abstraction make it a valuable tool for tackling complex computational problems.

A

Noted