single-shot task

Forum related to ERIKA Enterprise and RT-Druid version 2

Moderator: paolo.gai

Post Reply
szalokicsiga
Newbie
Posts: 24
Joined: Thu Oct 13, 2016 2:49 pm

single-shot task

Post by szalokicsiga » Wed Nov 02, 2016 4:10 pm

Hi!

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

Thank you!

e.guidieri
Full Member
Posts: 166
Joined: Tue May 10, 2011 2:05 pm

Re: single-shot task

Post by e.guidieri » Wed Nov 02, 2016 4:56 pm

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
Newbie
Posts: 24
Joined: Thu Oct 13, 2016 2:49 pm

Re: single-shot task

Post by szalokicsiga » Thu Nov 03, 2016 11:26 am

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
Full Member
Posts: 166
Joined: Tue May 10, 2011 2:05 pm

Re: single-shot task

Post by e.guidieri » Thu Nov 03, 2016 12:31 pm

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
Newbie
Posts: 24
Joined: Thu Oct 13, 2016 2:49 pm

Re: single-shot task

Post by szalokicsiga » Thu Nov 03, 2016 12:57 pm

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

Post Reply