Thread Interaction

We give an overview of the components and the execution flow that we will use in the solu-tion. There will be two active components. The first active component will be the sampling thread that will poke the interpreter. The second active component is the interpreter thread executing the Prolog text at hand.

 
Picture 1: Thread Interaction Port Sampling

Main Scenario Headless Thread:
1.    The headless thread sets the interpreter state to trace.

2.    The headless thread sleeps a larger amount of time.

3.    The headless thread sets the interpreter state to debug.

4.    The headless thread sleeps a smaller amount of time.

5.    The flow continues with step 1.

Main Scenario Interpreter Thread:       
1.    The interpreter thread executes an instruction in trace mode.

2.    The interpreter thread calls the debugger hook for a port.

3.    The custom hook updates the port counters.

4.    The flow continues with step 1.

Alternative Scenario Interpreter Thread
1a.1.    The interpreter thread executes an instruction in debug mode.

1a.2.    The flow continues with step 1.

For the interpreter thread there will be not much coding. The interpreter does already the polling of the trace flag and invokes the debugger hook for us. All we have to do is implement a custom hook that will update the port counters. We will draw upon the port statistics example already presented in the language reference manual of the development environment. We will present an enhanced version that will be able to show relative statistics

Finally we will need to implement the main scenario of the frame thread. Similar to the interpreter thread this is basically a forever loop. We do not show here how the thread can be started and stopped from the command line of the development environment. The full source code can be found in the appendix. Certain aspects will be explained in the subsequent sections.

Comments