sync_hirschberg_sinclair_second_edition#46
Conversation
…_sinclair_second_edition.tex.
krzysztof-turowski
left a comment
There was a problem hiding this comment.
Thank you very much - you probably need to read wider about the existing framework and its usage instead of reinventing infrastructure. So please follow other algorithms and conform to the general flow common to all of them.
| go run example/leader_undirected_ring_sync_franklin.go 10 | ||
| go run example/leader_undirected_ring_sync_prob_as_far.go 10 | ||
| go run example/leader_undirected_ring_async_hirschberg_sinclair.go 10 | ||
| go run example/leader_undirected_ring_async_hirschberg_sinclair_second_edition.go 10 |
There was a problem hiding this comment.
Rename everything to leader_undirected_ring_async_hirschberg_sinclair_2
| #### Synchronized undirected ring | ||
| 1. Franklin algorithm | ||
| 1. Hirschberg-Sinclair algorithm | ||
| 1. Hirschberg-Sinclair algorithm2.0 |
There was a problem hiding this comment.
You can remove it, since it's just a second implementation of the same algorithm
| package main | ||
|
|
||
| import ( | ||
| pathToCandidate "github.com/krzysztof-turowski/distributed-framework/leader/undirected_ring/sync_hirschberg_sinclair_second_edition" |
There was a problem hiding this comment.
Please remove pathToCandidate, just sync_hirschberg_sinclair_2 and it's fine + move github.com packages below system packages (leaving one line skip between them)
| // Shuffle the array | ||
| //rand.Seed(time.Now().UnixNano()) |
There was a problem hiding this comment.
Please remove it (or uncomment)
| writeChannel <- leader | ||
| } | ||
|
|
||
| //arr := generateShuffledArray(N) |
| wg.Add(N) | ||
| runner := func(candidate ICandidate) { | ||
| defer wg.Done() |
There was a problem hiding this comment.
Please migrate to the synchronizer (located in lib/lib_synchronizer.go, built by functions in lib/lib_graph.go) instead of reinventing the wheel - at least you could ask before re-implementing it.
| var input1, input2 <-chan []byte | ||
| var output1, output2 chan<- []byte | ||
| input1 = prevOutput | ||
| output1 = prevInput | ||
| input2 = nextInput | ||
| output2 = nextOutput |
There was a problem hiding this comment.
input1, input2 := prevOutput, nextInput
Here it's irrelevant since the whole function is to be removed, but please apply the shorthand notation elsewhere
| This pseudocode is more suitable for a solution based on maintaining references to neighboring processes. However, in the implementation I provided, solution stuck to to passing information through channels, requiring a slight modification in the code structure. Nevertheless the given pseudocode effectively reflects the algorithm's flow, as much, as it reduces the number of messages). | ||
|
|
There was a problem hiding this comment.
I suppose this could become irrelevant when you migrate to graph and synchronizer as it's implemented in the library.
| type randBit struct { | ||
| R *rand.Rand | ||
| } | ||
|
|
||
| func generateRandomBit() bool { | ||
| rB := randBit{ | ||
| R: rand.New(rand.NewSource(time.Now().UTC().UnixNano())), | ||
| } | ||
| return rB.R.Intn(2) == 0 | ||
| } |
There was a problem hiding this comment.
I guess this won't be needed too.
| pathToCandidate.BuildUndirectedRingAndRun(N, argsArr) | ||
| } | ||
|
|
||
| func checkN(N int) bool { |
There was a problem hiding this comment.
Please put it directly in code
2. Code fitted to framework rules 3. Removed unnecessary quote in README.md 4. Synchronizer has been skipped
…e-round Synchronizer implemented within the framework.
…simulating behavior of directed ring with "twisting" on base of undirected one. 2. Updated Makefile 3. Added quote in README.md 4. Added implementation of BuildRingWithOriginalTopology for possibility to accomplish task (1).
…ted ring version.
Everything together