single-shot task

Forum related to ERIKA Enterprise and RT-Druid version 2

Moderator: paolo.gai

Locked
szalokicsiga

single-shot task

Post by szalokicsiga »

Hi!

How can I configure a task as "single-shot"? (for initialization codes)

Thank you!
e.guidieri

Re: single-shot task

Post by e.guidieri »

You can achieve something like a "Single Shot Initialization TASK", with the AUTOSTART=TRUE; OIL TASK filed.

The best you can do is using this TASK to handle Idle time/Background activities (BG) too:

1) Declare the autostart TASK with the lowest priority in the system, this will let any other TASK preempt the BG (after the initialization, see following points).

2) Declare the SCHEDULE=NON policy, this will implicitly acquire the RES_SCHEDULER Resource in ERIKA, so the BG TASK cannot be preempted during the initialization.

3) Call the Schedule() service at the end of the initialization before entering in an infinite loop to handle BG activities, this will release the RES_SCHEDULER making you TASK actually preemptable.

To be honest this schema rely on an internal implementation detail and it's not fully OSEK compliant, but it works on ERIKA.

There is an OSEK portable way to handle this but is more configuration verbose and functionally equivalent.

Errico
szalokicsiga

Re: single-shot task

Post by szalokicsiga »

I tried this method, and if I declare SCHEDULE=NON, the task is not preemted after Schedule() calling. I declared also USERESSCHEDULER = TRUE.
By declaring SCHEDULE=FULL it works.
e.guidieri

Re: single-shot task

Post by e.guidieri »

So you are calling GetResource(RES_SCHEDULER); at TASK begin and ReleaseResource(RES_SCHEDULER); before the while loop, is it correct?

If yes, you are doing it correctly :)

Errico
szalokicsiga

Re: single-shot task

Post by szalokicsiga »

No, as you wrote SCHEDULE=NON policy will implicitly acquire the RES_SCHEDULER Resource, and Schedule() service will release the RES_SCHEDULER.
Locked