# Task Runtime

**URL:** <https://forums.freertos.org/t/task-runtime/18189>\
**Category:** Kernel\
**Created:** [September 12, 2023, 6:55am UTC](https://forums.freertos.org/t/task-runtime/18189 "2023-09-12T06:55:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![msauerpb](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@msauerpb](https://forums.freertos.org/u/msauerpb)\
**Post date:** [September 12, 2023, 6:55am UTC](https://forums.freertos.org/t/task-runtime/18189/1 "2023-09-12T06:55:48Z")

</div>

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

```auto
    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

```auto
>>> 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

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [September 12, 2023, 10:59am UTC](https://forums.freertos.org/t/task-runtime/18189/2 "2023-09-12T10:59:54Z")

</div>

> [@msauerpb](#):
>
> We have a main task which wait on signal from other task

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](https://www.freertos.org/RTOS-task-notifications.html).
