Unexpected high CPU usage reported by embOSView

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Unexpected high CPU usage reported by embOSView

    I'm working with embOS 3.52e on LPC2138/01, IAR 4.41 toolkit.

    The application is fairly simple, and currently is running with four tasks. When I look at the CPU utilization, all tasks are typically sitting at less than 0.5%. Several times per minute the utilization of one task goes way up and often sits at 100% for many seconds. There are also periods of "noise" where the utilization only goes up a few percent and maybe spikes to 10%. I have tried to test the system responsiveness by typing into a serial port. The system responds quickly and the output does not appear to be delayed at all. The task window on embOSView shows the one task at 100% or near it for the whole time. As best I can tell it does not matter if I assign the one active task the highest pri or lowest. It looks to me that the 100% utilization is not correct.

    Currently all but one are sleeping on long calls to OS_Delay or waiting on events that never happen. The one active task is awakened by OS_GetMail(), which is signaled by an ISR call to OS_PutMailCond() every 10ms. I have put calls in the code to set and clear test points when the code is executing the ISR that awakens the task. Also, in the task itself so I can see how long it is executing between times when it waits on the empty mailbox. The ISR and the task both execute in about 10us, which is close to 0.1% load each, not counting overhead. For the purpose of testing I have tried the code with all task functionality disabled, so the task only has to read the mailbox until it is empty.

    Any suggestions or insight into what is causing this or how I can debug it ?

    Thanks,
    George

    The 10ms period is
  • Hey gpontis,


    could you please make a screen shot and post it here? And/or could you post your application here? I guess your application file should be not to big, so I would like to test it myself, because until now I had no problems with embOSView and LPCxxxx CPU.
  • Hi Ralf,

    I have changed and simplified the application to only three tasks. The background (lowest pri) spikes to 100% once at startup and every few minutes thereafter. What is more of a concern now is that I have learned that the application crashes within half an hour when connected to embOSView. I have not tried it with the ebOSView cable unplugged. When embOSView is not configured (OS_UART = -1), I have not seen it crash.

    I am running with the debug library. Twice I have had it connected to the debugger when the crash happened, and it was reporting that an OS call was illegal inside an ISR. So far as I could tell I was not executing any ISR. There is only one OS call in one ISR that my code contains, a call to OS_Event_Set which is supposed to be allowable. No doubt I have made a mistake somewhere but I don't have a good idea how to debug this problem. I'd love to get to the bottom of it because there is probably a bug somewhere in my code that is at the root of the crash. I don't think that my app could be tested in isolation since there is a lot of serial communications. In fact no task will execute unless there is some data coming in over the serial port. If I can learn more about the nature of the problem maybe I can make a standalone demo.

    George
  • Hello George,

    "a call to OS_Event_Set which is supposed to be allowable"
    Did you use OS_EnterInterrupt() and OS_Leaveinterrupt()? I guess a lot of people forget this in their embOS interrupt routine.

    You should also send an email to support@segger.com, if you are still in support, but I am sure they will also ask
    you for a complete project, with which they can reproduce your issue.

    Perhaps you could post parts of your code here, e.g. your own interrupt routine?
    Until now I can think of two aspects:
    - there is a problem in the embOS BSP (uart)
    - you made a mistake in your code

    Did you test the original sample project from Segger on your target? I think it is a good idea to take the original project
    w/o any modifications and run it. If it runs w/o problems you should add your code step by step to the project.

    Ralf
  • Hi Ralf,

    Thanks for your additional comments and suggestions. You seem like you have a lot of knowledge and have probably been in this business for a while. I have too, so I did not miss the call to OS_EnterInterrupt/OS_LeaveInterrupt. Actually I used the ARM-specific embOS call to register my interrupt handler so it is called through OS_irq_handler. I verified that enter/leave are being called before and after my ISR is executed.

    I found a IAR demo board for the LPC2138 and have been paring down my app to find a minimum program that demonstrates the problem. I have been able to cut it back quite a bit, but what I have not been able to do yet is to get the problem to show up without having some UART communication with another part of my bigger system. I have been trying to simulate the communication with a loopback plug but I that has not done it yet. This is where I am stuck with trying to make an example that I can send to support.

    George
  • It looks like the issue is partly resolved. My system stack at 160 bytes was inadequate. After bumping it up and running my app overnight I see that the peak sys stack usage reached 164 bytes. I still see CPU usage on one task spike up to 100%, which I do not believe.