summaryrefslogtreecommitdiff
path: root/answers-thread.txt
diff options
context:
space:
mode:
authorMole Shang <[email protected]>2024-02-17 11:55:33 +0800
committerMole Shang <[email protected]>2024-02-17 12:22:07 +0800
commite8e0a7b4c97064eb5e9415726d7e38aaceccd3fd (patch)
treefb42ba5be7a8ae608b968266f62fd71fa889a89d /answers-thread.txt
parenta6af72924b115c1177d18d9b1eaba56623e4248b (diff)
parentd85aec2689c4250d0384904bdc11aa618c726bec (diff)
downloadxv6-labs-e8e0a7b4c97064eb5e9415726d7e38aaceccd3fd.tar.gz
xv6-labs-e8e0a7b4c97064eb5e9415726d7e38aaceccd3fd.tar.bz2
xv6-labs-e8e0a7b4c97064eb5e9415726d7e38aaceccd3fd.zip
Merge branch 'thread' into fs
Conflicts: .gitignore Makefile conf/lab.mk kernel/param.h
Diffstat (limited to 'answers-thread.txt')
-rw-r--r--answers-thread.txt10
1 files changed, 10 insertions, 0 deletions
diff --git a/answers-thread.txt b/answers-thread.txt
new file mode 100644
index 0000000..80dde35
--- /dev/null
+++ b/answers-thread.txt
@@ -0,0 +1,10 @@
+1. Why are there missing keys with 2 threads, but not with 1 thread?
+ With 1 thread, the put and insert are always interleaved.
+ No changes to hash table happen at the same time.
+ But with 2 threads, there will be race to access the hash table,
+ and this leads to the missing keys.
+
+2. Identify a sequence of events with 2 threads that can lead to a key being missing.
+ Suppose thread No. 1 is running the insert and so does thread No. 2.
+ They shall both insert a entry. But because they enter the insert function with the same hash table,
+ they could only insert one key at most, which causes a key being missing.