-
Notifications
You must be signed in to change notification settings - Fork 2
concurrent systems
MeadowView edited this page Feb 21, 2021
·
1 revision
- Anything dataflow is about asynchronous, autonomous, distributed systems -- unlike von-Neumann machine with cenral control (program counter), it needs distributed control where arrival of data represents control
- Wikipedia: Flow-based programming
- S. Edwards. Slides on Dataflow Languages
- E. Lee. Data Process Networks. IEEEPROC'95
- UTexas: Nice intro to Process Networks
- G. Kahn. The Semantics of A Simple Language for Parallel Programming. IFIP'74
- Wikipedia: https://en.wikipedia.org/wiki/Kahn_process_networks (very nice)
- concurrent processes communicate through one-way FIFO channels with unbounded capacity (Details)
- nonblocking send: need buffering
- blocking read: peeking FIFO not allowed
- channel is only shared between two processes: one consumer, one producer -- no multiple consumers/producers
- a process cannot wait on multiple channels at once
- Semantics:
- process defines a mapping from input sequences to output sequences (c.f. strings to strings)
- Scheduling algorithm does not affect behavior -- deterministic
- Simulation (or Scheduling):
- Let n processes be given.
- S. Tripakis. Slides on SDF/Kahn
- P. Kurshan. Reducibility in Coordination. IFIP'87
- Communication:
- transmit messages to named destination actors (no channels)
- Dijkstra. Guarded Commands, Nondeterminacy and Formal Derivation of Programs. (Why nondeterminacy? -- Scott Section 6.7)
- C. A. R. Hoare. Communicating Sequential Processes. CACM'78
- Communication:
- explicit unbuffered channels for message passing
- blocking send/blocking recv ==> requires rendezvous
- Guarded command (Dijkstra-style w/ nondeterminacy)
- Reactive systems are open systems and need to respond to a continual stream of stimuli from an environment which which they cannot synchronize.
- Some argue that streams and functions on streams are a natural way to model reactive systems.
- Two ways to model streams:
-
Recursive cons-model (Landin): defines streams recursively e.g. using cons-like list constructors -- treats them functionally using lazy semantics
- Can be thought of as (Python) generator -- coroutine that may be considered to be a particular method of representing a list in which the creation of each list element is delays until it is actually needed.
- Scheme models streams as two-element cell -- car contains the value of the head of the stream and cdr contains the procedure that computes the rest of the stream
- I-structures used in dataflow languages
- Channels: not functional because it is modified by appending new elements to it
-
Recursive cons-model (Landin): defines streams recursively e.g. using cons-like list constructors -- treats them functionally using lazy semantics
- Burns and Martin. Syntax-directed Translation of Concurrent Programs into Self-Timed Circuits. ARVLSI'88
- entries, events, tasks, fork, join, wait, delay
- class: has private var and procedures; class instance can be used by only one process
- monitor: has private vars and procedures; monitor instance can be shared by processes
- process: always-process
- Wikipage: contains bounded buffer example
- parbegin: fork-join
- input/output: process-to-process (not process-channel-process, which is more flexible)
- no automatic buffering: blocking input/output
- wikipedia: https://en.wikipedia.org/wiki/Futures_and_promises
- Scala futures and promises: http://docs.scala-lang.org/overviews/core/futures.html
-
futures: read-only placeholder view of a variable
- implicit future (need language support): Actor's
3 + future factorial(100000) - explicit future (in library): requires explicit "get" results of future (e.g.
java.util.concurrent.Future)- 1) check if computation is complete
- 2) to wait for its completion, and
- 3) to retrieve the result of the async computatoin
- implicit future (need language support): Actor's
- promises: writable, single assignment container which sets the value of the future
var running = true; // Set false to stop.
while (running) {
var time = await window.animationFrame;
context.clearRect(0, 0, 500, 500);
context.fillRect(time % 450, 20, 50, 50);
}var running = true; // Set false to stop.
tick(time) {
context.clearRect(0, 0, 500, 500);
context.fillRect(time % 450, 20, 50, 50);
if (running) window.animationFrame.then(tick);
}
window.animationFrame.then(tick);