Last active
May 10, 2024 20:41
-
-
Save aoli-al/ef6f2b4d8d14a2688bef9d49a443aaa3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Await Scenario | |
Thread t = Thread.currentThread(); | |
reschedule(); | |
// Lock 3 | |
if (L[o].owner != t && L[o].count > 0) { | |
E.remove(t); | |
W[o].add(t); | |
reschedule(); | |
} | |
// Lock 1 & 2 | |
L[o].owner = t; | |
L[o].count += 1; | |
synchronized (o) { | |
//... | |
reschedule(); | |
// Await 1 | |
L[o].owner = null; | |
L[o].count = 0; | |
C[o].H[o] = L[o].count; | |
C[o].S.add(t); | |
E.remove(t); | |
asyncReschedule(); | |
do { | |
o.wait(); | |
} while (!isRunning(t)); | |
// Await 2 | |
L[o].owner = t; | |
L[o].count = C[o].H[o]; | |
C[o].H[o] = 0; | |
//... | |
} | |
// Unlock 2 | |
L[o].count -= 1; | |
// Unlock 1 | |
if (L[o].count == 0) { | |
Thread selected = W[o].removeOne(); | |
E.add(selected); | |
} | |
// Signal Scenario | |
//... | |
synchronized(o) { | |
//... | |
// signal | |
Thread selected = C[o].S.removeOne(); | |
W[o].add(selected); | |
o.notify(); | |
o.notifyAll(); | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment