====== Week 10 ======
~~NOTOC~~
===== Channels, CSP, and Go =====
**//Continuing from where we left off last week//**
* Hoare's 1978 CSP paper: https://spinroot.com/courses/summer/Papers/hoare_1978.pdf
* Go implementation of examples from paper: https://godoc.org/github.com/thomas11/csp
* Rob Pike's Google I/O 2012 - Go Concurrency Patterns: https://youtu.be/f6kdp27TYZs
* Peter Welch's slides introducing CSP and occam-pi (but we will use Go this semester!)
* [[courses:cs377-201951:welch-lectures:top|Occam-pi Lecture Notes]]
* today:
* **//Objects Considered Harmful//** (slide 27 of motivation.pdf slides)
* even though we won't be programming in occam-pi, I want to give you a flavor of it
* because:
* ultimate lightweight processes!
* composition!
* Legoland: slide 83-end of basics.pdf \\ \\
* Demo and codewalk of csp-dining-philosophers.go
* Go language features highlighted:
* channels
* select
* Design basis for solution in Go: go routines (processes)
* room (communicates with philosophers over channels)
* for philosophers to enter/leave -- at most 4 at a time to prevent deadlocking, 5th philosopher blocks
* forks (communicate with philosophers over channels)
* philosophers (communicate with forks over channels) \\ \\
* Demo and codewalk: Sieve of Eratosthenes (Prime Number Sieve)
* copy the sample code from my directory to yours:
* cd into the directory where you have your sample Go code
* ''cp -r /home/mlsmith/cs377-examples/Go/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<-
// //
* Assignment 5 posted
* Sort Pump Gophers {{sort-pump.pdf|PDF}}
* Due: Friday, April 19th