Skip to content
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

Open
lemmy opened this issue Jan 26, 2021 · 5 comments
Open

Polish and extend tutorial #5

lemmy opened this issue Jan 26, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@lemmy
Copy link
Owner

lemmy commented Jan 26, 2021

Polish

  • Starvation -> NoStarvation
  • Invariant -> NoDeadlock or DeadlockFree (proof has theorem DeadlockFreedom)
  • Java take vs. TLA get action names
  • Align bound variable x in \E x \in waitSet... in Notify with Wait and Next, i.e. t
  • Inconsistent terminology around processes and threads
  • Comment and spec contradictory (conjunct even seems superfluous):
    \* ...there a fewer Poison messages in the buffer than (non-terminated)
    \* Consumers.
    \/ Cardinality(cons) < Cardinality({i \in DOMAIN buffer: buffer[i]=Poison})

Extend

Code pointers

@lemmy lemmy added the enhancement New feature or request label Jan 26, 2021
@lemmy lemmy changed the title Rename operators for clarity Polish and extend tutorial Jan 26, 2021
@lemmy
Copy link
Owner Author

lemmy commented May 1, 2021

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>

@lemmy

This comment has been minimized.

@lemmy
Copy link
Owner Author

lemmy commented May 4, 2021

@johnyf Do you think that starvation freedom (Starvation) for FairSpec can be proved with the new tlapm?

@lemmy
Copy link
Owner Author

lemmy commented Nov 29, 2021

The refinement BlockingQueue <- BlockingQueuePoisonApple below fails to check because BQ allows only Producer elements to be in buffer. Thus, append the Poison element to buffer in BQPA!Terminate violates the the refinement. The BQ spec should be more liberal s.t it does not assert anything about the elements in buffer. Alternatively, we could show refinement of BQPA with ProducerConsumer.tla (if it ever gets added to the repo).

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

@lemmy

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant