diff options
author | Mole Shang <[email protected]> | 2024-02-16 11:29:36 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2024-02-16 11:31:23 +0800 |
commit | edd523ffcb39c1c57944796fabfc71c70a10ce2e (patch) | |
tree | a37eaf56bbee9509f32a775793a61738b3d4bbac /answers-thread.txt | |
parent | a98c56a811142e5ede3332a7a444cca45f628769 (diff) | |
download | xv6-labs-edd523ffcb39c1c57944796fabfc71c70a10ce2e.tar.gz xv6-labs-edd523ffcb39c1c57944796fabfc71c70a10ce2e.tar.bz2 xv6-labs-edd523ffcb39c1c57944796fabfc71c70a10ce2e.zip |
lab thread: finish
Diffstat (limited to 'answers-thread.txt')
-rw-r--r-- | answers-thread.txt | 10 |
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. |