Lecture 8 Flashcards

1
Q

What is eager evaluation?

A

Arguments are evaluated before their procedure is called

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

What is the declarative concurrent model of computation DCKL?

A

An extension of DSKL

Can be extended using data-driven or demand driven concurrency

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

What is data-driven concurrency?

A

A thread of computation can execute when it has all its data

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

What is demand-driven concurrency?

A

A thread of computation can be executed no sooner than when the result of its execution is needed by another thread.

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

What does it mean to consume elements of a list while it is being created?

A

If we use threads to generate a list, and call browse on the list from another thread, it will display the elements as they are being created.

Browse consumes these elements.

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

What is the syntax for threads?

A

<statement> ::= thread <s> end
</s></statement>

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

What does a concurrent abstract machine contain?

A

Semantic stacks for each thread.

One single assignment store, shared across threads.

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

What does a scheduler do?

A

Chooses what executable semantic stack to run. The top most statement is poped and executed.

A stack is executable when the topmost statement is not frozen.

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

What is a fair scheduler?

A

Each semantic stack (thread) is eventually chosen.

Stacks are chosen with equal frequency.

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

In a concurrent system, when is computation finished?

A

When all semantic stacks are removed.

A stack is removed when it is empty.

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

What is the semantics of a thread?

(thread <s> end, E)</s>

A

Create a new stack
Push (<s>, E) on this stack</s>

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

When is a data-driven model of computation declarative?

A

One of these are true:

All executions of the program must have the same result (logical equivalent)

All executions must fail

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

What can make concurrent programs non-declarative?

A

If there is a unification error where two threads binds the same variable to different non-unifiable values. The program will always fail, however, the variable will take one of the bindings. If the variable is part of the result, it is not declarative. If it is not part of the result, it is declarative.

Introdusing exceptions

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

What are the operations of the thread module?

A

Thread.this

Thread.suspend T (need to be explicitly resumed)

Thread.resume T

Thread.preempt T (can be scheduled again by scheduler)

Thread.terminate T (can no longer be run)

These are not part of the declarative model

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

What is a stream?

A

Potentially infinite datastructure.

Elements can be added to end, and read from beginning.
These to operations can be performed concurrently.

Producer process: Adds elements
Consumer process: Reads elements

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

How are streams implemented?

A

Using list-like structures with an unbound end:

declare UnboundEnd
Stream = 1|2|3|UnboundEnd

17
Q

How can streams be read from?

A

Read by starting from the head.

Stream = Head|RestOfStream

Can now use Head

18
Q

How can we extend the stream?

A

Binding the tail:

UnboundTail = NewElement|NewUnboundTail

19
Q

Give an example of streams being read concurrently while being produced.

A

thread Integers = {Enumerate 0 100} end
thread Result = {Sum Integers}

{Browse Result}

Enumerate: Producer
Sum: Consumer

20
Q

What affect the performance of a producer-stream-consumer pipeline?

A

Producer much faster than consumer. Can run out of memory because the producer allocates much faster than the consumer deallocates.

Producer is slower, then the consumer must wait.

Production and consumption speed can vary.

21
Q
A