"6.824 distributed systematic study of just" going to be some of the short listed articles, the problem I encountered in learning MIT 6.824 2020 distributed systems and record their own thinking. After completion of this course, we want to have the energy to fragmented system problems sorted out.
Background problem
In Lecture 2-RPC and Threads, the teacher provides some crawler crawler.go . The program implements three different implementations of crawlers, respectively,
- Serial reptiles
- Achieved through shared state concurrency reptiles and mutex
- Concurrent achieved by passage reptile
In the "2", there is such a part code is:
func ConcurrentMutex(url string, fetcher Fetcher, f *fetchState) {
fmt.Println(url)
f.mu.Lock()
already := f.fetched[url]
f.fetched[url] = true
f.mu.Unlock()
if already {
return
}
urls, err := fetcher.Fetch(url)
if err != nil {
return
}
var done sync.WaitGroup
for _, u := range urls {
done.Add(1)
go func(u string) {
defer done.Done() // defer保证了无论下一行函数是否正确执行,WaitGroup计数器都能-1,使done.Wait()可以不必一直等待
ConcurrentMutex(u, fetcher, f)
} (u)
}
done.Wait()
return
}
In the classroom students have made anonymous function go func(u string) {...}
, u do not pass go, because u is the string, that is an immutable object. In fact, immutable string refers to string itself is immutable, but we can change the quote of the string, it's a reference point to another string. So there need to pass the value of u go.
Do the following three comparative experiments: #TODO