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

David Gay dgay42 at gmail.com
Fri Oct 21 18:36:46 PDT 2005


[I'm trying to separate the issues into separate emails]

On 10/21/05, Cory Sharp <cory at moteiv.com> wrote:
>  For instance, my
> modified CC2420Control interface now looks like this, notice the
> "uint8_t rh" parameters:
>
> interface CC2420Control {
>   command result_t TunePreset( uint8_t rh, uint8_t channel );
>   command result_t TuneManual( uint8_t rh, uint16_t freq );
>   command uint8_t GetPreset();
>   command uint16_t GetFrequency();
>   async command result_t VREFOn();
>   async command result_t VREFOff();
>   async command result_t OscillatorOn( uint8_t rh );
>   async command result_t OscillatorOff( uint8_t rh );
>   async command result_t TxMode( uint8_t rh );
>   async command result_t TxModeOnCCA( uint8_t rh );
>   async command result_t RxMode( uint8_t rh );
>   command result_t SetRFPower( uint8_t rh, uint8_t power );
>   command uint8_t GetRFPower();
>   async command result_t enableAutoAck( uint8_t rh );
>   async command result_t disableAutoAck( uint8_t rh );
>   async command result_t enableAddrDecode( uint8_t rh );
>   async command result_t disableAddrDecode( uint8_t rh );
>   command result_t setShortAddress( uint8_t rh, uint16_t addr );
> }
>
> Those parameters means, "This command is arbitrated.  If you call me
> with an ungranted resource handle such as RESOURCE_NONE, I will defer
> your request if the resource is not available.  If you call me with a
> granted resource handle, I will execute immediately."

So you want implicit reservation, i.e., if the resource is idle
reserve it for this call only? (if you don't, ignore the rest of this
email ;-)) I actually believe this is an extremely bad idea with async
split-phase calls, because it's very easy to introduce race
conditions. The only ways I know to really avoid them is to either use
a parameterised interface, indexed by client id. Or to make
essentially all async code be atomic.

The problem shows up when you write:

  if (sub_request() == SUCCESS)
     itsforme = TRUE;

  ...

  async event sub_request_done() {
     if (itsforme)
       be_happy();
  }

If sub_request_done happens too early, you'll ignore it. The alternate
options suffer from similar problems, except:
a) wrapping the request if in an atomic (and you tend to have to do
the same for the completion event inside the thing which signals
sub_request_done())
b) parameterising the interface so that you don't see other
component's done events

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