GetResource() / ReleaseResource()

Forum related to ERIKA Enterprise and RT-Druid version 2

Moderator: paolo.gai

Post Reply
moonckim
Newbie
Posts: 15
Joined: Fri Feb 04, 2011 9:18 pm

GetResource() / ReleaseResource()

Post by moonckim » Mon Apr 04, 2011 8:32 pm

How can I delcare a resource in EE? I do not see the "DeclareResource()" API in the EE basic reference manual. Can I simply define it, e.g., "ResourceType S1;" ?

Can I use GetResource() / ReleaseResource() pair to block the calling task (put it into a waiting state) when the resource is already occupied by another task? Is there any sample code for using this pair for such purposes, e.g., a typical producer / consumer example?

Thanks,
Moon

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re: GetResource() / ReleaseResource()

Post by paolo.gai » Tue Apr 05, 2011 7:29 am

Dear Moon,

DeclareResource is a void declaration, and it is not used by ERIKA (although it is defined to comply with the standard). When you declare a resource, it is defined into the eecfg.h created by RT-Druid in the Debug directory.

About the producer/consumer: Resources in oSEK uses the immediate priority ceiling scheduling algorithm, meaning that resources are:
- non blocking
- provoke a delayed execution of tasks

On the other hand, the waiting state is related to Events... and the only blocking primitive provided by the standard is WaitEvent.

In other words, you can try to implement a producer/consumer using 2 methods:
- events for synchronization + resources
- Others use asynchronous activations of tasks (that is, they use an Activate task to activate a basic task that consume...

I hope it helps...

PJ

Post Reply