This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

what does the "_SlNonOsMainLoopTask()" mean, when should I call it? where should I call it?

Hi experts,

what does the "_SlNonOsMainLoopTask()" mean, when should I call it? where should I call it?

thanks,

Joseph Zhang

  • Hi Joseph,

    _SlNonOsMainLoopTask() is used in NON-OS scenarios. It is used for loops which wait on global variables which get updated asynchoronously (e.g. callback functions).
    Using a while loop waiting for an asynchoronous message would block the main loop. The _SlNonOsMainLoopTask()  loops on a function pointer table which gets updated in the interrupt context indicating that an asynchorounous message. If the main loop calls this function waiting on a global, the callback function is executed, thus updating the required global variables.Regards,

    Prathyusha Teja.I

  • would you describe the answer by simple grammar? your sentence is too long to understand, I'm sorry.Another question, how long do I need to wait between twice callback this function? thanks

     

     

    Joseph Zhang

  • Hi Joseph,

    The _SlNonOsMainLoopTask() is essentially used for capturing data updated using asynchronous callbacks.

    For example, After sl_WlanConnect()  call, the main function has to wait for the connected asynchronous event. This event is notified by the callback function "SimpleLinkWlanEventHandler". While waiting for the callback function, the main can be on a while loop before proceeding further.

    In order for the CPU to capture such asynchronous calls, we call the SlNonOsMainLoopTask() inside the while loop.This function captures such callback functions and executes them. The callback updates the data that is used to break out of the while loop.

    Usage of SlNonOsMainLoopTask() in NON-OS context is demonstrated in mdns and ent_wlan examples.

    Regards,

    Prathyusha Teja.I

     

     

     

     

  • Hello Prathyusha,

    Thanks for the explanation.

    However, like Joseph asked, how long do I need to wait between twice callback this function?

    At what intervals should i call the _SlNonOsMainLoopTask(); in my NonOs based application??

    Regards,

    Abhishek.

  • Hi,
    I got the concept of _SlNonOsMainLoopTask();
    We need to call it in order to get asynchronous events.

    Thanks and regards,
    Abhishek.
  • Hi,

    I would like to ask a similar question: where is the appropriate place to put _SlNonOsMainLoopTask in the program?

    My program has three interrupts, one at 10000hz, one at 2hz, and one at 0.2hz. The faster interrupt has priority on the slowest. In the slowest interrupt, I have an http connection.

    I tried to put _SlNonOsMainLoopTask in the main loop, but sometimes the wifi connection is messed up. I assume that it is because SlNonOsMainLoopTask is interrupted.

    I tried to put it in the 2 hz interrupt, but then it misses events.

    Any idea?