Author Topic: Porting code to a task that originally ran in a forever loop  (Read 2739 times)

Offline FAQ

  • Newbie
  • *
  • Posts: 27
    • View Profile
Porting code to a task that originally ran in a forever loop
« on: August 12, 2020, 12:47:39 AM »
Is the use of uTaskerStateChange(OWN_TASK, UTASKER_GO);
as suitable method to allow a task to operate continuously to allow code that originally ran in a forever loop to be used in a task?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Porting code to a task that originally ran in a forever loop
« Reply #1 on: August 12, 2020, 12:48:37 AM »
Hi

Yes, the UTASKER_GO (or UTASKER_POLLING, which will continue polling after receiving events) is a way or emulating forever loops in ported code into a task.

The original functionality is usually quite easy to achieve and then you can look at increasing efficiency by stopping the polling (looping) operation when you know that a timer or event is being waited for before new activity is required.

Remember that, when low power mode is enabled, the processor is switched to low power mode when no tasks are running (that is, all are waiting for events or timers). Any task operating in polling mode will stop the low power mode from being entered and so also means that there is usually a higher power consumption.

Regards

Mark