02158  Concurrent Programming - Lab 4: Go Concurrency - solution proposal
Technical University of Denmark DTU
02158 Concurrent Programming        Fall 2024
Lab 4: Go Concurrency - solution proposal
Home Plan Material  

A: Voting System

Basic solution using a clever (but quite standard) way of numbering the nodes of a binary tree:

multi_voting.go

Note that the collector should just pass along any votes received on the input channels without any processing.

Also note the trick, that for each input channel there is a local channel reference which is set to nil when the channel is closed thereby effectively blocking for further use of the respective select case.

Mitigated solution using a Ticker from the time package:

multi_voting_mitigated.go

B: Sieve of Eratosthenes

No solution provided.

Hans Henrik Løvengreen, Nov 21, 2024