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
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.