[Tinyos-devel] Bug in Resource.request interaction with ResourceRequested.requested

Eric Decker cire831 at gmail.com
Mon Aug 11 17:21:17 PDT 2008


I am making heavy use of arbitration in a T2 based mote.  I've discovered
what lookslike incorrect behaviour.  The code looks like:

=>async command error_t Resource.request[uint8_t id]() {
    signal ResourceRequested.requested[resId]();
    atomic {
      if(state == RES_CONTROLLED) {
        state = RES_GRANTING;
        reqResId = id;
      }
      else return call Queue.enqueue(id);
    }
    signal ResourceDefaultOwner.requested();
    return SUCCESS;
  }


The problem is ResourceRequested.requested[resId]() gets signaled
no matter what.  "resId" holds the value of the last holder of the resource
it doesn't get modified when a resource owner does a release.

I would assert that a ResourceRequested.requested shouldn't be signaled
unless the resource is actively owned by resId.  ie.  signal only if state
== RES_BUSY.
So if a resource owner does a release it is possible (Resource.request is
async) for a
request to come in.  If ResourceRequested.requested is signaled, I assert
that
this is wrong.

This can be protected inside of the ResourceRequested.requested
event by checking for ownership but I think it would be cleaner to check for
RES_BUSY
inside of Resource.request.  I would assert ResourceRequested.requested
should
only be signaled when the resource is owned and a new request comes in.  It
only should
be signaled to the current owner.

I observed the failure when executing the following code:

        call UARTResource.release();
        call GPSMsg.reset();
        call GPSTimer.startOneShot(DT_GPS_MAX_REQUEST_TO);
        call UARTResource.request();

Even though we do the release,  when the request is executed, I observe that
UARTResourceRequested.requested is getting signalled which seems odd.

thoughts,

eric



-- 
Eric B. Decker
Senior (over 50 :-) Researcher
Autonomous Systems Lab
Jack Baskin School of Engineering
UCSC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-devel/attachments/20080811/2d80499f/attachment.htm 


More information about the Tinyos-devel mailing list