Concurrent / Parallel Flashcards

1
Q

Simple concurrent implementation of a stack?

A

Using mutexes and sync request on every operation.

type Stack struct {
list *list.List
lock sync.Mutex
}
func (this *Stack) Size() int {
this.lock.Lock()
defer this.lock.Unlock()
return this.list.Len()
}

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

Explain:

Concurrency vs Parallelism?

A

Concurrency is about modeling a solution to allow composition of independent processes which execute in the same time.

Parallelism is about simultanious execution or potentially related processes in a parallel way.

Concurrency is not parallelism, but it potentially enables parallelism.

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

Communicating Sequential Processes - CSP?

A
  • Defined by Hoare
  • represents formal language for describing patterns of interactions in concurrent systems
  • based on message passing via channels
How well did you know this?
1
Not at all
2
3
4
5
Perfectly