Page 1 of 1

single-shot task

Posted: Wed Nov 02, 2016 4:10 pm
by szalokicsiga
Hi!

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

Thank you!

Re: single-shot task

Posted: Wed Nov 02, 2016 4:56 pm
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

Re: single-shot task

Posted: Thu Nov 03, 2016 11:26 am
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.

Re: single-shot task

Posted: Thu Nov 03, 2016 12:31 pm
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

Re: single-shot task

Posted: Thu Nov 03, 2016 12:57 pm
by szalokicsiga
No, as you wrote SCHEDULE=NON policy will implicitly acquire the RES_SCHEDULER Resource, and Schedule() service will release the RES_SCHEDULER.