Author Topic: tasking  (Read 7560 times)

Offline cagdask

  • Newbie
  • *
  • Posts: 4
    • View Profile
tasking
« on: April 12, 2011, 11:56:13 AM »
Hi I want my task not to run whenever a message comes but only at periodic intervals. I mean it should handle the message only at next round. Can one of those do this job?

{ "X-turnstile-application",       fnTurnstileApplication,  LARGE_QUE,  (DELAY_LIMIT)(2 * SEC),(DELAY_LIMIT)(3 * SEC), UTASKER_GO} or
{ "X-turnstile-application",       fnTurnstileApplication,  LARGE_QUE,  (DELAY_LIMIT)(2 * SEC),(DELAY_LIMIT)(3 * SEC), UTASKER_STOP}

BTW what is the exact difference between those? I have already read the uTasker operating system basics. But it is unclear...
Thx...

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: tasking
« Reply #1 on: April 13, 2011, 02:37:48 PM »
Hi

The method to use for starting with a delay and then periodically scheduling is:

{ "X-turnstile-application",       fnTurnstileApplication,  LARGE_QUE,  (DELAY_LIMIT)(2 * SEC),(DELAY_LIMIT)(3 * SEC), UTASKER_STOP}

Using UTASKER_GO as initial state would be incorrect since it would cause the task to immediately run, thus cancelling the delay.


If a task receives messages (timer events, interrupt events or messages from other tasks) it will be immediately scheduled so that it can handle the message as soon as possible. A periodic task will be scheduled periodically without sending a message to it.
If you don't want to interpret the message you can simply return from the task without reading its input queue - this would result in messages being queued (the input queue to the task should of course be dimensioned adequately). However, it is then not easy to know whether the task was sheduled due to an event or the period. Therefore it may be best to use two tasks - one without a queue and only the periodic rate - one with a queue to which messages are sent to. Normally, the task with queue simply returns and leaves its input queue alone. When the periodic task is scheduled it can set a flag and schedule the task with queue [uTaskerStateChange(TASK_X, UTASKER_ACTIVATE);]. The task with queue is then started and can see that it should now read its input queue; it also clears the flasg so that it ignores everything until the next period is complete.

Regards

Mark