PDA

View Full Version : Queueing preempting task


Alexandre Ouellet
05-07-2008, 01:49 PM
Hello,

I am facing a case and I am not sure about what should be the normal behavior of a TaskExecutor (TE).

Sequence of events:

t1: tasksequence#1 priority=0 PREEMPT_NOT
t2: tasksequence#2 priority=10000 PREEMPT_ONLY
also at t2: tasksequence#3 priority=1 PREEMPT_AND_ABORT_ALL

at this time, the active tasksequence is tasksequence#2. And tasksequence#1 and tasksequence#3 are queued.

t3: End of tasksequence#2

The next tasksequence will be tasksequence#3 because of its priority. However, it seems that the PREEMPT_AND_ABORT_ALL is not executed and that tasksequence#1 remains in the queue. Is this the normal behavior?

If it is, how can I tell flexim to do its PREEMPT_AND_ABORT_ALL and get rid of tasksequence#1.

Thanks a lot,

Alex

Anthony Johnson
05-07-2008, 02:02 PM
Alexandre,

The TE will only perform the preemption type if the TE takes up the tasksequence immediately when you call dispatchtasksequence(). In other words, it only aborts all if the dispatching of the tasksequence actually causes preemption to occur. Otherwise, the tasksequence will queue up and will not abort all when it is started. To get around this, you could add a sendmessage task as the first task of the tasksequnce, and as part of the message, clear the content of the TE's tasksequence queue: clearcontent(gettasksequencequeue(current));

Good Luck,

Goksin Yilmaz
05-08-2008, 07:27 AM
Hello,

I am a bit puzzled about this discussion. For example: "it only aborts all if the dispatching of the tasksequence actually causes preemption to occur". If the preemption type is "PREEMPT_AND_ABORT_ALL", how can one dispatch that tasksequence without preemption happening?

The other question is before using "clearcontent(gettasksequencequeue(current))", would it not make sense to re-assign the tasksequence? Obviously that tasksequence was created for some purpose, how is that purpose achieved if that tasksequence is cleared from the content of the tasksequence queue of the TE it was assigned to?

Thanks in advance...

Anthony Johnson
05-08-2008, 09:22 AM
Preemption will not occur if the tasksequence is dispatched while the object is doing another tasksequence that is also preempting with a higher priority. In the example, tasksequence#2 is preempting and it has a higher priority than tasksequence#3, so when you dispatch tasksequence#3, it's not going to preempt tasksequence#2 because tasksequence#2 is "more important". Instead it will go into the tasksequence queue, and not perform the preemption.

If you don't want to abort the other tasksequences, then don't use PREEMPT_AND_ABORT_ALL. The whole idea behind PREEMPT_AND_ABORT_ALL is that you don't want to finish those other tasksequences for some reason, which is basically what clearcontent(gettasksequencequeue(current)) does if you didn't get the preemption to happen. If you still want those task sequences finished eventually, then use PREEMPT_ONLY. This is the option people will use 99% of the time.

You can also re-dispatch those unfinished tasksequences back to other objects by connecting the outputs of the TE back to the input ports of its dispatcher. This will cause the TE to pass preempted tasks back to the dispatcher for re-dispatch, although that can cause problems, for example, if the TE has already loaded a part. You don't want to tell another TE to unload the part that the first TE loaded, so be careful there as you may need to add some extra logic to the PassTo to get it to work right.

There's a page in the user manual that talks about this stuff. It's under Task Sequences > Task Sequence Preempting.