Week 10
Channels, CSP, and Go
- Last week:
- Peter Welch039;s Occam-pi Lecture Notes
- Go demo and starter code: see last week039;s notes for details
- Demo and codewalk of
csp-dining-philosophers.go
- Demo and codewalk: Sieve of Eratosthenes (Prime Number Sieve)
sieve.go- Go language features highlighted:
- Only one looping construct in Go: for loop
- all three parts are optional: init statement, conditional expression, post statement
- channel declarations in function headers
- can specify syntactically whether channel is for reading from:
<-chan
or writing to:
chan<-
- To run this program:
$ go run sieve.go
- Monitor the running program:
- use
topcommand for system info while running - run
lscputo remind us about system resources - how many processes (goroutines) are running concurrently (if not in parallel)?
- use
wc -landwatchto monitor
- Assignment 5 posted
- Sort Pump Gophers PDF
- see a similar example in occam on slides 13–31 of PHW039;s replicators lecture notes which can be found here
- be sure to read the advice section of the assignment description closely—I tried to document most of the Golang learning curve questions I encountered in the hopes of helping you!
- Due: Tue, April 14th
Linda and Tuple Space
- History
- proposed by David Gelernter Wikipedia
- while a PhD student at SUNY Stoneybrook
- now a professor at Yale
- overcome a great deal personally!
- origins of name
- off-color humor
- implementations
- C-Linda (Martin Schultz and David Gelernter)
- Ruby implementation no less off-color!
- communications decoupled in 3 dimensions:
- time
- space
- destination
- Lecture Notes: PDF
- Demo of Ruby/Rinda program
- from Wikipedia example:
http://en.wikipedia.org/wiki/Rinda_(Ruby_programming_language)- link no longer live
- sample code: copy from my directory
$ cp -r /home/mlsmith/cs377-examples/rinda/ ~/cs377/