-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polish and extend tutorial #5
Comments
Failed attempt to use Linchecker: package org.kuppe;
import org.jetbrains.kotlinx.lincheck.LinChecker;
import org.jetbrains.kotlinx.lincheck.annotations.Operation;
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.ModelCheckingCTest;
import org.jetbrains.kotlinx.lincheck.verifier.VerifierState;
import org.jetbrains.kotlinx.lincheck.verifier.linearizability.LinearizabilityVerifier;
import org.junit.Test;
@ModelCheckingCTest(requireStateEquivalenceImplCheck = false, threads = 2, verifier = LinearizabilityVerifier.class)
public class DeadlockChecker extends VerifierState {
// BQ with capacity 1 deadlocks for more than 2 running threads RT s.t. RT ==
// Producers \cup Consumers
private final BlockingQueue<Integer> bq = new BlockingQueue<>(1);
@Operation(blocking = true, causesBlocking = true)
public void put() throws InterruptedException {
bq.put(42); // Value is known to be irrelevant.
}
@Operation(blocking = true, causesBlocking = true)
public Integer take() throws InterruptedException {
return bq.take();
}
@Test
public void test() {
LinChecker.check(DeadlockChecker.class);
}
@Override
protected Object extractState() {
return bq;
}
} <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.kuppe.app</groupId>
<artifactId>blockingqueue</artifactId>
<version>1.0-SNAPSHOT</version>
<name>BlockingQueue</name>
<url>http://github.com/lemmy/BlockingQueue</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>lincheck-jvm</artifactId>
<version>2.12</version>
<type>jar</type>
</dependency>
</dependencies>
<repositories>
<repository>
<id>kotlin-bintray</id>
<name>Kotlin Bintray</name>
<url>https://kotlin.bintray.com/kotlinx/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
</project> |
This comment has been minimized.
This comment has been minimized.
@johnyf Do you think that starvation freedom ( |
The refinement A == INSTANCE BlockingQueue
\* Replace Poison with some Producer. The high-level
\* BlockingQueue spec is a peculiar about the elements
\* in its buffer. If this wouldn't be a tutorial but
\* a real-world spec, the high-level spec would be
\* corrected to be oblivious to the elements in buffer.
WITH buffer <-
[ i \in DOMAIN buffer |-> IF buffer[i] = Poison
THEN CHOOSE p \in (Producers \ waitSet): TRUE
ELSE buffer[i] ]
(* The bang in 'A!Spec' makes 'A!Spec' an invalid token in the config BlockingQueueSplit.cfg. *)
ASpec == A!Spec |
Polish
Starvation
->NoStarvation
Invariant
->NoDeadlock
orDeadlockFree
(proof has theoremDeadlockFreedom
)take
vs. TLAget
action namesx
in\E x \in waitSet...
inNotify
withWait
andNext
, i.e.t
processes
andthreads
BlockingQueue/BlockingQueuePoisonPill.tla
Lines 95 to 97 in a064863
Extend
Incorporate advanced liveness that makesb0bbddc Polish and extend tutorial #5 (comment)BlockingQueue.tla
even withoutwaitSeqC
... starvation free. See @xxyzzn PlusCal variant below:buffer
a sequence, theView = <<Len(buffer), waitSet>>
achieves a state-space reduction identical to modelingbuffer
as a counter.notifyOther
but onlynotifyAll
(PulseAll)See if Kotlin's Linchecker finds the deadlock** No support for
wait/notify/notifyAll
yet (https://twitter.com/nkoval_/status/1365050321077157892)Code pointers
The text was updated successfully, but these errors were encountered: