
4.10 Tracing and Replay for Monitors
Outline:
simple M-sequences of monitor-based programs
tracing and replaying simple M-sequences during debugging
modifying the SC and SU monitor toolboxes to support tracing and replay
complete M-sequences and a technique for using complete M-sequences to test
monitor-based programs
applying reachability testing to monitor-based programs
4.10.1 Simple M-sequences
Let M be a monitor that is implemented using one of the monitor toolboxes.
An execution of a program that uses M can be viewed as a sequence of P() and V()
operations on the semaphores in the implementation of M:
a simple SYN-sequence for M is the collection of simple PV-sequences for the
semaphores in the implementation of M.
we can replay an execution of a program that uses M by applying the replay method
that was presented in Chapter 3 for replaying PV-sequences of semaphore-based
programs.
A simpler method is based on the property of entry-based execution:
The execution of threads inside an SU monitor is completely determined by the order
in which the threads enter the monitor via monitor calls, and the values of the
parameters on these calls.
The execution of threads inside an SC monitor is completely determined by the order
in which the threads enter the monitor via monitor calls, the values of the parameters
on these calls, and the order in which signaled threads reenter the monitor.
The execution of threads in a monitor having entry-based execution is completely
determined by the order in which the threads (re)enter the monitor and the values of the
parameters on the calls to the monitor.
Let CP be a concurrent program that uses monitors. The synchronization objects in CP
are its monitors. The synchronization events in a simple SYN-sequence of CP depend on
the type of monitors being used:
SC monitors: A simple SYN-sequence for an SC monitor is a sequence of events of the
following types:
entry into the monitor by a calling thread
reentry into the monitor by a signaled thread
SU monitors: A simple SYN-sequence for an SU monitor is a sequence of events of the
following type:
entry into the monitor by a calling thread
Simple SYN-sequences of monitors are called simple M-sequences:
An event in a simple M-sequence is denoted by the identifier (ID) of the thread that
executed the event.
The simple M-sequence of a program CP is a collection of simple M-sequences for the
monitors in CP.
We can replay an execution of CP by replaying the simple M-sequence for each monitor.
Consider the SC bounded buffer monitor in Listing 4.3. A possible simple M-sequence of
boundedBuffer for a single Producer thread (with ID 1) and a single Consumer thread
(with ID 2) is: (2, 1, 2, 1, 1, 2, 2).