Week 4: Parallel Programming Flashcards

1
Q

How does memory work in multicore processors?

A

Each core has L1 cache.
In some processors, each core has L2, in others, L2 is shared.
All cores share L3 cache and DDR3 DRAM (main memory - via comm bus).

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

What is data coherence?

A

Quality of being logical and consistent.

Data must remain coherent.

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

Name a coherence mechanism?

A

A write to a memory location must cause all other copies of this location to be invalidated or deleted from the caches they are in.

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

Describe MSI Protocol?

A

Each cache line is labelled with a state.
M: Cache block has been modified.
S: Caches may be sharing block.
I: Cache block is invalid.

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

How should you program multicore platforms?

A

1: Program directly targets processor cores (error-prone)
2: Concurrency platform: Abstracts cores, handles synchronization and communication protocols, performs load balancing

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

What are the 3 ways in which a server may deal with a client?

A

Sequential: Process one client at a time, other clients may have to wait a while
Concurrent: Process multiple clients at the same time
Parallel: Process multiple tasks at the same time

Parallel tasks are always concurrent, but concurrent tasks may not be parallel.

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

What is a thread?

A

The smallest sequence of instructions that can be managed independently by the scheduler.
Execute concurrently in a stack region, each with it’s own copy of stack related info.
Share heap, global data and other resources (opened files etc.)

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

What is a possible solution for multiple parameters for a function on a pthread?

A

Pack parameters into a compound object, with wrapper function.
Pass compound into function.

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

What is a race condition?

A

When two+ threads need to perform operations on same data, but result of computation depends on order of operations.
Mutual exclusion prevents this.

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

What are 3 synchronization methods in pthreads?

A

Join: Blocking function, waits for thread to finish.
Mutual Exclusion: Objects that lock and unlock, section between lock and unlock is the critical section. Can result in deadlock (trylock).
Condition variables: Synchronize based on value of data, thread waits until data is a certain value.

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

Why is a mutex needed with a condition variable?

A

Signal (only checked in waiting state) may arrive before Thread 1 enters the waiting state - deadlock.

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

What are read-write locks?

A

Lock functions for read and read-write.

Multiple threads can read (if no thread is writing) but only one thread can write.

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