[Tinyos-host-mote-wg] Re: [Tinyos-2.0wg] Resource handles

David Gay dgay42 at gmail.com
Fri Oct 21 18:52:28 PDT 2005


[I think this is the last separate answer]

On 10/21/05, Cory Sharp <cory at moteiv.com> wrote:
> Another thing I want is for lower level components to *assert* that it
> is okay for them to use the resource, even if the aribtration request
> happens above them.  (This is what I meant by "nesting" of requests.)
> I'm not quite sure how this works in the current TOS2 Resource and
> ResourceUser interfaces work to achieve this.  If it's possible, it
> looks complicated, and if it's simple, I'd to see it how it works.

Well the way I've done it in the past is that the code is generally
written to assume it has the resource. If there's both a high-level
and low-level component providing access to the same interface, then
they share the same arbiter. So clients at whichever level are
arbitrated with respect to each other, and their implementations all
assume the resource is reserved when they're called (if you're into
runtime checking, then you make sure the client id is passed to the
requests too). Something like:

#define HIGHLEVEL_RESOURCE LOWLEVEL_RESOURCE
configuration HighLevelC {
  provides interface Resource[int client];
  provides interface HighLevelService;
}
implementation {
  components LowLevelServiceC, HighLevelCodeP;

  Resource = LowLevel.Resource;
  HighLevelService = HighLevelCodeP;
  HighLevelCodeP.LowLevelService -> LowLevelServiceC;
}

#define LOWLEVEL_RESOURCE "my lowlevel favourite string"
configuration LowLevelC {
  provides interface Resource[int client];
  provides interface LowLevelService;
}
implementation {
  components LowLevelCodeP;
  components new MyFavouriteArbiter(LOWLEVEL_RESOURCE) as Arbiter;

  Resource = Arbiter;
  LowLevelService = LowLeveCodeP;
}

Hey presto, resource nesting :-)

You proably want to expose ResourceUser too in HighLevelServiceC and
LowLevelServiceC, actually.

David

_______________________________________________
Tinyos-2.0wg mailing list
Tinyos-2.0wg at Mail.Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-2.0wg


More information about the Tinyos-host-mote-wg mailing list