Concurrency Flashcards

1
Q

sequential computation

A

each task -> required to complete computation, terminates before the next one can start

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

concurrent computation

A

tasks execute in overlapping time periods

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

synchronous programming

A

task -> started
program waits for it to complete before moving on

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

asynchronous programming

A

task -> started
program moves on before it completes

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

concurrency

A

two or more computations are being executed in overlapping time periods

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

3 types of concurrent activities

A
  1. processes
  2. parallelism
  3. threads
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

processes

A

chunky large coarse grained, few in numbers

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

parallelism

A

fine grained, large in number, small actions

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

threads

A

in between

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

concurrency models

A

shared data state, dataflow, message passing

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

shared data state

A

“flock of sheep grazing in grass”

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

dataflow

A

“data flowing through the computer agents”

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

message passing

A

workers share no data -> communicate via mailbox that are unique to each computational agent

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

thread is an abstraction for

A

executing a program

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

thread encapsulates what 3 things

A
  1. instructor pointer
  2. call stack
  3. memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

can a single program call multiple threads at the same time?

A

yes, all with separate pointers, call stacks, and memory

17
Q

threads in java

A

lightweight sub processes that share memory

18
Q

what is the one thread every java program has

19
Q

main thread can cause

A

new threads to come into existence and run concurrently

20
Q

thread states

A

new, runnable, non-runnable, running, terminated

21
Q

2 ways of implementing threads

A
  1. extending thread class
  2. implement Runnable -> thread intended class
22
Q

issues of concurrent tasks interfering on shared data

A

busy waiting
race conditions
dead lock
starvation

23
Q

ways to prevent issues with concurrent tasks

A

test and set
spin waiting
mutex lock
semaphores
monitors

24
Q

condition “variable”

A

container of threads that are waiting for a certain condition

25
Q

mutex

A

class like structure wrapping around a shared resource

allows for locking and mutual exclusion

26
Q

3 main operations on condition variables

A

wait c, m
signal c
broadcast c

27
Q

wait c, m

A

where c is a condition var and m is a mutex (lock) of the monitor

28
Q

signal c (notify c)

A

called by thread to indication the assertion Pc is true

29
Q

broadcast c (notifyAll c)

A

similar op to signal but wakes up all threads in c’s wait queue