Task Runtime

Hi,
this is my first project with FreeRTOS. I have to port our old software based on Xil Kernel (Virtex-5 PPC) to FreeRTOS with Zynq Ultrascale+.
We have a main task which wait on signal from other task

    while(1)
    {
        // check32MiByteBorderFiguereRam(ctr++);


        if (DROP_PROFI == 0)
        {
            if (receivedSignalData & ERS_InitProfi)
            {
                profiLowLevelData.init();
            }
        }


        if (receivedSignalData & ERS_DataReceived)
        {
            for (CommPortInfoBlockProfiArray::iterator iter = s_CommPortInfoBlockProfiArray.begin();
                 iter != s_CommPortInfoBlockProfiArray.end(); iter++)
            {
                iter->workOnReceivedPackets();   // SPS
            }

            do
            {
                CommPort_USB.InterpreteRxMsg();   // USB
            } while (CommPort_USB.RxListEmpty() != 0);

            s_ServerData.workOnReceivedPacketPlain();
        }

        const uint32_t waitTime     {flashCheckDone ? INFINITE_WAIT_TIME : 0};
        receivedSignalData          = signal_wait(CSignalWrapper::TestApp_pid, ERS_AllSignals, waitTime);

        if (!flashCheckDone || (receivedSignalData & ERS_CheckFlash))
        {
            flashCheckDone          = !s_Flash_Board.CheckAndContinueLongOperation();
            if (!flashCheckDone)
            {
                taskYIELD();
            }
        }
    }

At the moment, there aren’t any signals, so no function in the if case will be called.

I create a task with perodical print the runtime info

>>> Start Main
>>> RS232CMD >> prvMainTask Task
unsigned int=4, int=4, long=8, short=2

Task=StatTask, Priority=10, Time=0, Percent=<1%
Task=MainTask, Priority=10, Time=100010, Percent=100%
Task=IDLE, Priority=0, Time=0, Percent=<1%
Task=Tmr Svc, Priority=19, Time=0, Percent=<1%

Task=StatTask, Priority=10, Time=560, Percent=<1%
Task=MainTask, Priority=10, Time=200560, Percent=99%
Task=IDLE, Priority=0, Time=0, Percent=<1%
Task=Tmr Svc, Priority=19, Time=0, Percent=<1%

Task=StatTask, Priority=10, Time=1130, Percent=<1%
Task=MainTask, Priority=10, Time=301120, Percent=99%
Task=IDLE, Priority=0, Time=0, Percent=<1%
Task=Tmr Svc, Priority=19, Time=0, Percent=<1%

So I can see that our main task uses 99% cpu time. Why is the task time so high?
I would have expected the IDLE process to have more time.
Thank you for your help.
BR
martin

Where are you waiting for signal? If you mean the global variables ( receivedSignalData, ERS_InitProfi, ERS_DataReceived etc.), then your task will hog the CPU and likely that is what you are seeing. You need to use some FreeRTOS primitive to wait for a signal - for example, use task notification to wait for a notification so that the task does not consume CPU when it is blocked. You can read more about task notifications here - FreeRTOS task notifications, fast Real Time Operating System (RTOS) event mechanism.

2 Likes