150 likes | 462 Vues
Programming Project #1 Concurrent Game of Life. Due Friday, March 20. Assignment. Implement a version of Conway’s Game of Life on multiple processes or threads In this project, all processes or threads are on the same computer
E N D
Programming Project #1Concurrent Game of Life Due Friday, March 20 Project 1
Assignment • Implement a version of Conway’s Game of Life on multiple processes or threads • In this project, all processes or threads are on the same computer • In a future project, they will be distributed across different computers Project 1
Objective • Refresh your memory about concurrency and synchronization • Build a concurrent application that has non-trivial synchronization demands • Lay the groundwork for a non-trivial distributed computation Project 1
Conway’s Game of Life • See http://www.math.com/students/wonders/life/life.html • Introduced by John Conway • Scientific American, April 1970, p. 120 • Played on an “infinite” grid of squares • Each square may be occupied or unoccupied • Rules define how occupancy changes from one generation to next Project 1
Rules of Game of Life • If an occupied square has on 0 or 1 occupied neighbors, it dies of loneliness • If an occupied square has 4 or more occupied neighbors, it dies of overcrowding • If an occupied square has 2 or 3 occupied neighbors, it survives to the next generation • If an unoccupied square has precisely 3 occupied neighbors, it “gives birth,” becoming occupied in next generation Project 1
Rules of Game of Life (continued) • Game terminates if • Grid becomes empty • Pattern of occupancy repeats itself from a previous pattern • A predefined number of generations is reached Project 1
Concurrent Game of Life • Divide grid into fixed-size subgrids • 3232 cells for this project • Each subgrid is computed by a separate process or thread • Called a player • Each player must get information about cells on boundary from neighboring players • Each player must tell neighboring players about its cells on its boundary Project 1
Concurrent Game of Life (continued) • Parent process or thread creates each player • Initial value of subgrid (3232 array) • Array of objects denoting nearest neighbors • Null object player is on a boundary • Invoking concurrent life life X Y gen filename print pause • X, Y are number of players in x- and y-dimension • gen is number of generations to play • filename is file with initial grid pattern • print, pause for debugging Project 1
Concurrent Game of Life (continued) • File of initial grid positions • Lines of “x” and “o” characters • “x” denotes occupied; “o” denotes unoccupied • No spaces between characters • Center initial value in array of grids • E.g., oxxxxooxo denotes the R-pentomino Project 1
Implementation • Any of C, C++, or Java • Must compile and run on Fossil Lab machines • Synchronization primitives • Java SYNCHRONIZED objects • Semaphores on C++ classes • … messages, other forms of IPC Project 1
Testing • Concurrent programs are harder than sequential ones • At least three non-trivial test patterns • Exercise all sub-grids • Test communication across boundaries • Discuss further testing in write-up Project 1
Submission • Submit via myWPI • Source code & header files • Makefile • Test patterns and output • Write-up • We will • Compile/build using make • Run your test cases • Run our test cases Project 1
Grading • Successful submission — 10% • Clear, cogent write-up — 10% • Success build on Fossil Lab machines with no errors or warnings — 15% • At least three non-trivial test patterns – 15% • Successful run of your test patterns — 25% • Successful run of our test patterns — 25% Project 1
Questions? Project 1