SPRAA56
4.2Measuring Task Scheduling Latencies
Scheduling latency is defined as the time between a wakeup signal (semaphore post) to a pending task and the actual start of that task's execution.
DSP/BIOS provides a mechanism for measuring scheduling latency with the TSK_settime and TSK_deltatime APIs. These functions accumulate the difference in time from when a task is made ready to the time TSK_deltatime is called. The placement of the TSK_deltatime API therefore determines what is actually measured. Scheduling latency can be measured by placing the API directly after the task’s blocking call, which may be MBX_pend, SCOM_getMsg, or a similar API.
Time differences are accumulated in each task's internal STS object, so there is no need to create a separate STS object to measure scheduling latency.
This technique is used for each task in the instrumented application. For example, in the input task, the beginning of the
while(1) // Tsk main processing loop begins
{
/* TSK_deltatime called immediately after last blocking call, to measure scheduling latency */
TSK_deltatime(TSK_self());
...
SCOM_getMsg(fromProctoInput, SYS_FOREVER); /* end of main processing loop */
...
}
4.3Measuring End-to-End Latencies
In the example application, encode and decode occur within the same system. However, in many designs the encoder and decoder could be part of separate systems. To accurately measure latency, you need a method of indicating frame numbers and types and a method of measuring latency on both ends of the system. This example application provides frame numbering and identification as I or P frames, as well as a rudimentary measurement of latency from input to output.
The code to implement the latency measurement is divided into two sections. The first section makes a timestamp for a frame if the latency measurement has been completed for the previously timestamped frame. This code section is included in the video input task:
//measure input to output frame latency if (benchCapVid.captodisplay.done) {
benchCapVid.captodisplay.frameNum = frameCaptureCnt; benchCapVid.captodisplay.latency = CLK_getltime(); benchCapVid.captodisplay.done = 0;
}
12DSP/BIOS