Skip to content

Commit

Permalink
Adding concurrency related methods to CProver.java
Browse files Browse the repository at this point in the history
Specifically: startThread, endThread, atomicBegin, atomicEnd and
getCurrentThreadID.
  • Loading branch information
Degiorgio committed May 10, 2018
1 parent 784b6dd commit 46849e9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/java_bytecode/java_bytecode_convert_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,11 @@ void java_bytecode_convert_method(
"nondetWithNull",
"nondetWithoutNull",
"notModelled",
"atomicBegin",
"atomicEnd",
"startThread",
"endThread",
"getCurrentThreadID"
};

if(std::regex_match(
Expand Down
47 changes: 47 additions & 0 deletions src/java_bytecode/library/src/org/cprover/CProver.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public final class CProver
{
public static boolean enableAssume=true;
public static boolean enableNondet=true;
public static boolean enableConcurrency=true;

public static boolean nondetBoolean()
{
Expand Down Expand Up @@ -115,6 +116,52 @@ public static <T> T nondetWithoutNull()
return null;
}

public static void startThread(int id)
{
if(enableConcurrency)
{
throw new RuntimeException(
"Cannot execute program with CProver.startThread()");
}
}

public static void endThread(int id)
{
if(enableConcurrency)
{
throw new RuntimeException(
"Cannot execute program with CProver.endThread()");
}
}

public static void atomicBegin()
{
if(enableConcurrency)
{
throw new RuntimeException(
"Cannot execute program with CProver.atomicBegin()");
}
}

public static void atomicEnd()
{
if(enableConcurrency)
{
throw new RuntimeException(
"Cannot execute program with CProver.atomicEnd()");
}
}

public static int getCurrentThreadID()
{
if(enableConcurrency)
{
throw new RuntimeException(
"Cannot execute program with CProver.getCurrentThreadID()");
}
return 0;
}

public static void assume(boolean condition)
{
if(enableAssume && !condition)
Expand Down

0 comments on commit 46849e9

Please sign in to comment.