Package org.mpi_sws.jmc.runtime
Class JmcRuntime
java.lang.Object
org.mpi_sws.jmc.runtime.JmcRuntime
The Runtime environment complete with a scheduler and configuration options used by the model
checker.
Calls to the runtime are made by the instrumented byte code. These calls are used to record events occurring during the execution of tasks or allow for scheduling changes. For example, the runtime can be used to record Thread creation and deletion.
The runtime is a static class that stores minimal states and delegates calls to the Scheduler which retains all the state.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic LongAdds a new task to the runtime and creates a future for that task.static LongReturns the current task id.static voidinitIteration(int iteration, JmcModelCheckerReport report) Initializes the runtime with the main thread for a given iteration.static voidUpdates the TaskManager to terminate the task with the given ID and yields control to the scheduler to schedule other tasks.static voidPauses the task.static voidstatic voidresetIteration(int iteration) Resets the runtime for a new iteration.static voidsetup(JmcRuntimeConfiguration config) Sets up the runtime with the given configuration.static voidsetupReplay(JmcRuntimeConfiguration config) static voidtearDown()Tears down the runtime by shutting down the scheduler adn clearing the task manager.static voidTerminates the task with the given ID.static voidupdateEvent(JmcRuntimeEvent event) Adds a new event to the scheduler which is passed to the strategy.static <T> TAdds a new event to the runtime and yields the control to the scheduler.static <T> Tstatic <T> Tyield()Pauses the current task that invokes this method and yields the control to the scheduler.static voidPauses the task with the given ID and yields the control to the scheduler.
-
Constructor Details
-
JmcRuntime
public JmcRuntime()
-
-
Method Details
-
setup
Sets up the runtime with the given configuration.- Parameters:
config- the configuration (instance ofJmcRuntimeConfiguration)
-
setupReplay
- Throws:
JmcCheckerException
-
tearDown
public static void tearDown()Tears down the runtime by shutting down the scheduler adn clearing the task manager. -
initIteration
Initializes the runtime with the main thread for a given iteration.Initializes the scheduler with the main thread and marks it as ready.
- Parameters:
iteration- the iteration number
-
resetIteration
public static void resetIteration(int iteration) Resets the runtime for a new iteration. -
recordTrace
public static void recordTrace() -
yield
public static <T> T yield()Pauses the current task that invokes this method and yields the control to the scheduler. The call returns only when the task that invoked this method is resumed. -
yield
Pauses the task with the given ID and yields the control to the scheduler. The call returns only when the task with the given ID is resumed.Use with Caution! It is meant to be called when a new concurrent task starts and yields with the new task id. Should not be used otherwise.
- Parameters:
taskId- the ID of the task to be paused- Throws:
HaltTaskExceptionHaltExecutionException
-
pause
Pauses the task.- Parameters:
taskId- the ID of the task to be paused
-
wait
-
join
Updates the TaskManager to terminate the task with the given ID and yields control to the scheduler to schedule other tasks.- Parameters:
taskId- the ID of the task to be terminated
-
currentTask
Returns the current task id.- Returns:
- the current task id
-
updateEvent
Adds a new event to the scheduler which is passed to the strategy.- Parameters:
event- to be added- Throws:
HaltTaskException
-
terminate
Terminates the task with the given ID.- Parameters:
taskId- the ID of the task to be terminated
-
updateEventAndYield
Adds a new event to the runtime and yields the control to the scheduler.- Parameters:
event- the new event- Throws:
HaltTaskException
-
addNewTask
Adds a new task to the runtime and creates a future for that task.- Returns:
- the ID of the new task
-