Comments (7)
FWIW, it is safe to assume a thread exit/join pair is synchronizing like a pair of release/acquire. Yes, you cannot reorder a thread join with later instructions.
from cs431.
Similar question concerning case kaist-cp/helpdesk#19:
Causality test case 19
Initially, x = y = 0
Thread 1:
join thread 3
r1 = x
y = r1
Thread 2:
r2 = y
x = r2
Thread 3:
r3 = x
if (r3 != 42)
x = 42
Behavior in question: r1 == r2 == r3 == 42
Decision: Allowed. This is the same as test case 17, except that thread 1 has been
split into two threads.
Why casualty test case 19 is wrong? I have an assumption that if "joining thread" is allowed to be reordered with later instructions, then case kaist-cp/helpdesk#19 becomes the same as case kaist-cp/helpdesk#17, where behaviour is Allowed. However, if "joining thread" is never reordered with later instructions, then behaviour is Disallowed. So, is my assumption("joining thread" is never reordered) right reason why behaviour is Disallowed?
Thank you!
For reference:
Causality test case 17
Initially, x = y = 0
Thread 1:
r3 = x
if (r3 != 42)
x = 42
r1 = x
y = r1
Thread 2:
r2 = y
x = r2
Behavior in question: r1 == r2 == r3 == 42
Decision: Allowed. A compiler could determine that at r1 = x in thread 1,
is must be legal for to read x and see the value 42. Changing r1 = x
to r1 = 42 would allow y = r1 to be transformed to y = 42 and performed
earlier, resulting in the behavior in question.
from cs431.
Again, you're reordering instructions beyond what's allowed. For example, in test case 16, r1=x and x=1 cannot be reordered because they're accessing the same location.
from cs431.
What about joining the thread? Is it also not allowed to reorder the moment of joining the thread?
from cs431.
Concerning case 16. I tried using the promising semantics, but got "Allowed" result. Where did I go wrong in my reasoning?
- Initial views:
- Thread 1 makes the promise X = 1, Thread 2 makes the promise X = 2. Both are certified, as those promises can be fulfilled when their threads are executed in isolation.
- After thread 1 is executed, r1 = 2 and promise X = 1 is re-certified and fulfilled.
- After thread 2 is executed, r2 = 1 and promise X = 2 is re-certified and fulfilled.
For reference:
Causality test case 16
Initially, x = 0
Thread 1:
r1 = x
x = 1
Thread 2:
r2 = x
x = 2
Behavior in question: r1 == 2; r2 == 1
Decision: Allowed.
from cs431.
- is wrong. t1's view is pointing to X=2 after reading it, so it cannot fulfill an earlier message X=1.
from cs431.
Closing, but feel free to reopen it if you have followup questions.
from cs431.
Related Issues (20)
- [Question] I get VALID?=timeout with full score log HOT 4
- [Lecture] Suggestion on teaching promising semantics HOT 1
- Optional Q&A session on June 5th (Wed)
- [Question] Understanding of access hazard & ABA hazard HOT 1
- Server rebooting scheduled (Jun 5, Wed, 10pm~) HOT 1
- [Question] zip is not installed on server HOT 2
- gg.kaist.ac.kr down for preparing for the final exam HOT 1
- [Question] find_harris_herlihy_shavit relaxed load for tag HOT 6
- [Question] Timeout on growable_array stress_concurrent with cargo_asan HOT 2
- [Question] How to get previous node of bucket sentinel? HOT 8
- [Question] Hazard Pointers: is it safe to protect a pointer to invalid memory? HOT 5
- [Question] Code lines for maintaining the invariants of stack/queue HOT 1
- [Question] About the problem of 2022 Fall HOT 2
- [Question] ordering in stack push for maintaining invariant HOT 1
- Final claim session on June 17th (Mon) HOT 4
- [Question] HW 7 reason for having atomicUsize type in hazard field HOT 2
- [Question] [HW7] Failed Basic Tests in hazard.rs HOT 3
- [Question] HW7 Dropping the Hazard Bag HOT 3
- [Question] Partial Points on HW7 HOT 1
- [Question] err happend when run cargo run hello_server in terminal HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cs431.