====== Week 13 ====== ~~NOTOC~~ ===== Final Assignment / Parallel Composition in Golang ===== ==== Final Assignment ==== * Due: end of classes * Tue, May 5, 11:59pm * Marc's office * Logistics * handout: paper copy of full assignment and problem descriptions * submit electronically via submit377 script: $ submit377 final my-final * //The S'mores Problem// * background clip from The Sandlot (S'mores scene): https://youtu.be/XlddDZkkxCc * implement using Ruby/Rinda where processes coordinate using tuples as semaphores to make S'mores * //The Water Molecule Problem// * chem background: Water molecule made up of two hydrogen atoms and one oxygen atom * implement using Golang, represent atoms as goroutines that must coordinate to form a water molecule (also a goroutine) ==== Parallel Composition in Golang ==== * this is ongoing research I've been doing with my RAs going back to before the pandemic * recall Legoland as implemented in Peter Welch's occam slides: [[https://www.cs.vassar.edu/_media/courses/cs377-202651/welch-lectures/basics.pdf|PDF]] * implementing Legoland in golang presents a challenge: no PAR! * demo without PAR * demo with a PAR * and some lambdas... * demo of sort pump with PAR and Replicated PAR ==== Simulating Models of Concurrency ==== * Discussion: modeling one model of concurrency with another * shared memory (critical sections, etc.) * we've seen implementing semaphores with monitors/condition variables (Java) * can we model condition variables with semaphores? * Golang: channels (message passing) * motto: //Don't communicate by sharing memory, share memory by communicating.// * simulate memory accesses with a goroutine? * Ruby/Rinda: Linda and Tuple Space * tuples are semaphores! * immutable so no race conditions / critical sections * similar perils to using semaphores, but offer more possibilities * Simulate Linda/TS with another model? * with combination of dictionaries, nested dictionaries, hashmaps * shared memory with semaphores * goroutines to protect access * other ideas? * We don't always get to choose our language/library/stack