Code Monkey home page Code Monkey logo

Comments (3)

Shynar88 avatar Shynar88 commented on September 23, 2024

Similar question concerning casuality test kaist-cp/helpdesk#14

Causality test case 14

Initially, a = b = y = 0, y is volatile

Thread 1:
r1 = a
if (r1 == 0)
y = 1
else
b = 1

Thread 2:
do {
r2 = y
r3 = b
} while (r2 + r3 == 0);
a = 1;

Behavior in question: r1 == r3 = 1; r2 = 0

Decision: Disallowed In all sequentially consistent executions, r1 = 0 and
the program is correctly synchronized. Since the program is correctly
synchronized in all SC executions, no non-sc behaviors are allowed.


Why can't we reorder Thread 2 in the following way?

Thread 1:
r1 = a
if (r1 == 0)
y = 1
else
b = 1

Thread 2:
a = 1;
do {
r2 = y
r3 = b
} while (r2 + r3 == 0);

Scheduling goes as following:
Thread 2
a = 1;
Thread 1
(all lines executed)
Thread 2
(rest of the lines executed)

In this way r1 == r3 = 1; r2 = 0

from cs431.

jeehoonkang avatar jeehoonkang commented on September 23, 2024

You're reordering instructions beyond what is allowed. For example, in test case 12, you cannot reorder a[r1] = 0 with r2 = a[0]. The promising semantics define which reorderings are allowed and which are not, so I recommend you to execute those test cases in the promising semantics to see what can happen.

from cs431.

jeehoonkang avatar jeehoonkang commented on September 23, 2024

Closing, but feel free to reopen it if you have followup questions.

from cs431.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.