To capture the activities of a monitor, the History Graph window has four more tags:
Hoare Monitors
Recall that a thread that executes a condition variable wait always waits, and a thread that executes a condition variable signal always yields the monitor to another thread. Therefore, after a CW tag, a thread is blocked and its history bar has a red portion. Once this thread is released and starts its execution, its history bar will have a CA tag, meaning it is active again. The history bar section between a CA tag and its immediate CW tag is in red.
Because a thread that executes a condition variable signal must yield the monitor, after a CY tag, this thread's history bar also has a red portion. If this signal causes the release of a thread that is waiting on the signaled condition variable, the signaling thread becomes inactive and will become active again some time later. When this thread starts running, its history bar will have a resume tag MR. Therefore, between the CY tag and the MR tag, the thread is inactive and is colored in red. After the MR tag, the thread is active and is running. Of course, the history bar after a MR tag is in green. The following snapshot contains a number of CW, CY, CA and MR tags.
Because the thread that has a CW tag or a CY tag yields the monitor, another thread can run. This thread that gains the control of the monitor may be a thread waiting to enter the monitor or a thread that is inactive (i.e., re-entering). To help understand who causes whom to run, click on the Monitor button in the Monitor window will display this relation. This relationship is shown with black line segments connecting tags. For example, if a thread executes a condition variable wait, a CW tag is shown. Since this wait causes the monitor to become empty (i.e., no inactive threads), a new thread will be allowed to enter. Therefore, a line segment is shown between a CW tag and a MA (i.e., monitor active) tag. This is a wait-active link. If a thread executes a signal, a CY tag is shown. This signal may release a thread from a condition variable, which will run eventually. When the signaled thread runs, a line segment connecting a CY tag on the history bar of the signaling thread and a CA on the history bar of the released thread will be shown. These connections that depict the yield/active relations are referred to as signal-active links.
The above snapshot has three wait-signal links (i.e., CW-MA relations). For example, near the left edge of the window, thread Philosopher0 executes a condition variable wait. The monitor becomes empty and is given to thread Philosopher1 that was blocked by its MonitorBegin() call. Therefore, a line segment connects a CW (condition variable wait) tag of thread Philosopher0 and a MA (active in monitor) tag of thread Philosopher1.
There are two signal-active links (i.e., CY-CA relations) in the above snapshot. For example, in the middle portion of the window, thread Philosopher4 executes a condition variable signal and yields the monitor. The monitor is then given to thread Philosopher0 which was blocked due to a condition variable wait. Therefore, a line segment connects a CY (yielding the monitor) tag of thread Philosopher4 and a CA (condition variable active) tag of thread Philosopher0.
In the right portion of the window, there are two MR tags on the history bar of thread Philosopher4. The first shows a CY-MR relation, which indicates thread Philosopher4 yielded the monitor due to a signal (CY) and resumed its execution later (MR). There is no links to this MR tag because thread Philosopher4 runs due to other thread in the monitor can run (i.e., threads Philosopher0 and Philosopher2 are blocked on condition variables and threads Philosopher1 and Philosopher3 are waiting to enter). The second one is a ME-MR relation, which indicates the exit of thread Philosopher3 causes thread Philosopher4 to resume its execution.
We have seen the Monitor window on a previous page. To help visualize condition variable related information, it has two more components. See the snapshot below. The Threads Reentering Monitor subwindow shows all inactive threads. A thread is inactive if it is released from a condition variable wait or yields the monitor due to a signal in a Hoare monitor. The snapshot below shows that thread Philosopher0 is inactive (or reentering).
The bottom part of the Monitor window may have more than one subwindows, each of which corresponds to a condition variable. The condition variable name is shown in the top part, and all threads that are waiting on that condition variable are listed in that subwindow. In the snapshot below, condition variable WaitChopStick3 (resp., WaitChopStick4) has one waiting thread, Philosopher3 (resp., Philosopher4), and the remaining three condition variables WaitChopStick0, WaitChopStick1 and WaitChopStick2 have no waiting thread.