Author Topic: Tasks in polling mode.  (Read 6217 times)

Offline Fausto_F

  • Newbie
  • *
  • Posts: 3
    • View Profile
Tasks in polling mode.
« on: March 18, 2008, 09:31:10 PM »
Hi Mark,

I've made some tests with tasks in polling mode to measure how fast they can run using an oscilloscope (toggling a pin).

When I run my toggle task with all the other default tasks, the periodicity was about 14us.
Running just my task, the periodicity was about 5us.

Are these delays typical? I thought a little slow to a 60MHz processor.

Thanks again.

Fausto


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Tasks in polling mode.
« Reply #1 on: March 18, 2008, 11:10:31 PM »
Fausto

The code that you are testing is basically running the scheduler:
   uTaskerSchedule();

This searches through the task list to find tasks ready to run and will also disable and enable interrupts while checking whether the task has to be delivered a timer event when woken.

The task is then called with a pointer to its table (used mainly as a reference to its input queue).

To verify the speed, it is necessary to know exactly how many instructions this involves - also whether the code has been compiled with maximum optimisation for speed (the project is set up to compile for smallest code size so there may be some improvement when compiled for best speed).

I don't know whether a scheduling speed of 5us is typical with only one task - obviously with more tasks needing to be managed, the scheduling speed reduces. However I have found that one is often a little disapointed with the time required to do some tasks - often because there are rather more instructions involved (often due to the compiler unnecessarily shifting data between registers or re-collecting data which is already loaded) and that some instructions take more clock cycles than initially expected....

In addition, the requirement to protect some critical code from interrupts involves a little lost time - however this is also necessary otherwise a system can become unstable when such interrupts could arrive and cause critical data to be corrupted.

Regards

Mark