[Tinyos-2-commits] CVS: tinyos-2.x/tos/system/arbiters ArbiterP.nc, 1.1.2.5, 1.1.2.6 ControlledArbiterP.nc, 1.1.2.2, 1.1.2.3

Kevin Klues klueska at users.sourceforge.net
Wed Jul 5 05:01:30 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/system/arbiters
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv6691/tos/system/arbiters

Modified Files:
      Tag: tos-2-resource-pm-eval-cand
	ArbiterP.nc ControlledArbiterP.nc 
Log Message:
Changes to the Resource interfaces and arbiter implementations.  Now has support for immediateRequest again, and no longer need a separate PriorityArbiter because of the introduction of the ResourceRequested interface.  In fact the Resource interface is now back to what it was originally, with changes to the ResourceController interface and the introduction of the ResourceRequested interface simplifying the state machines in the arbiters.

See previous check in logs to read about these changes to the ResourceController interface.

Index: ArbiterP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/system/arbiters/Attic/ArbiterP.nc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** ArbiterP.nc	27 Jun 2006 21:09:38 -0000	1.1.2.5
--- ArbiterP.nc	5 Jul 2006 12:01:27 -0000	1.1.2.6
***************
*** 74,77 ****
--- 74,78 ----
    provides {
      interface Resource[uint8_t id];
+     interface ResourceRequested[uint8_t id];
      interface ArbiterInfo;
    }
***************
*** 91,114 ****
    
    task void grantedTask();
!   
!   /**
!     Request the use of the shared resource
!     
!     If the user has not already requested access to the 
!     resource, the request will be either served immediately 
!     or queued for later service.  
!     A SUCCESS value will be returned and the user will receive 
!     the granted() event in synchronous context once it has 
!     been given access to the resource.
!     
!     Whenever requests are queued, the current owner of the bus 
!     will receive a requested() event, notifying him that another
!     user would like to have access to the resource.
!     
!     If the user has already requested access to the resource and
!     is waiting on a pending granted() event, an EBUSY value will 
!     be returned to the caller.
!   */
    async command error_t Resource.request[uint8_t id]() {
      atomic {
        if(state == RES_IDLE) {
--- 92,98 ----
    
    task void grantedTask();
!   s
    async command error_t Resource.request[uint8_t id]() {
+     call ResourceRequested.requested[resId]();
      atomic {
        if(state == RES_IDLE) {
***************
*** 123,126 ****
--- 107,111 ----
  
    async command error_t Resource.immediateRequest[uint8_t id]() {
+     call ResourceRequested.immediateRequested[resId]();
      atomic {
        if(state == RES_IDLE) {
***************
*** 210,213 ****
--- 195,202 ----
    default event void Resource.granted[uint8_t id]() {
    }
+   default event void ResourceRequested.requested[uint8_t id]() {
+   }
+   default event void ResourceRequested.immediateRequested[uint8_t id]() {
+   }
    default async command void ResourceConfigure.configure[uint8_t id]() {
    }

Index: ControlledArbiterP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/system/arbiters/Attic/ControlledArbiterP.nc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** ControlledArbiterP.nc	27 Jun 2006 21:09:38 -0000	1.1.2.2
--- ControlledArbiterP.nc	5 Jul 2006 12:01:27 -0000	1.1.2.3
***************
*** 74,77 ****
--- 74,78 ----
    provides {
      interface Resource[uint8_t id];
+     interface ResourceRequested[uint8_t id];
      interface ResourceController;
      interface ArbiterInfo;
***************
*** 84,113 ****
  implementation {
  
!   enum {RES_IDLE, RES_GRANTING, RES_IMM_GRANTING, RES_BUSY};
    enum {NO_RES = 0xFF};
    enum {CONTROLLER_ID = controller_id};
  
!   uint8_t state = RES_IDLE;
    norace uint8_t resId = CONTROLLER_ID;
    norace uint8_t reqResId;
    
    task void grantedTask();
-   task void requestedTask();
    
    async command error_t Resource.request[uint8_t id]() {
      atomic {
!       if(state == RES_IDLE) {
          state = RES_GRANTING;
          reqResId = id;
-         post requestedTask();
-         return SUCCESS;
        }
      }
!     return call Queue.enqueue(id);
    }
  
    async command error_t Resource.immediateRequest[uint8_t id]() {
      atomic {
!       if(state == RES_IDLE) {
          state = RES_IMM_GRANTING;
          reqResId = id;
--- 85,115 ----
  implementation {
  
!   enum {RES_CONTROLLED, RES_GRANTING, RES_IMM_GRANTING, RES_BUSY};
    enum {NO_RES = 0xFF};
    enum {CONTROLLER_ID = controller_id};
  
!   uint8_t state = RES_CONTROLLED;
    norace uint8_t resId = CONTROLLER_ID;
    norace uint8_t reqResId;
    
    task void grantedTask();
    
    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 ResourceController.requested();
!     return SUCCESS;
    }
  
    async command error_t Resource.immediateRequest[uint8_t id]() {
+     signal ResourceRequested.immediateRequested[resId]();
      atomic {
!       if(state == RES_CONTROLLED) {
          state = RES_IMM_GRANTING;
          reqResId = id;
***************
*** 118,122 ****
      if(resId == id)
        return SUCCESS;
!     state = RES_IDLE;
      return FAIL;
    }
--- 120,124 ----
      if(resId == id)
        return SUCCESS;
!     atomic state = RES_CONTROLLED;
      return FAIL;
    }
***************
*** 133,137 ****
          else {
            resId = CONTROLLER_ID;
!           state = RES_IDLE;
          }
          released = TRUE;
--- 135,139 ----
          else {
            resId = CONTROLLER_ID;
!           state = RES_CONTROLLED;
          }
          released = TRUE;
***************
*** 168,175 ****
    */    
    async command bool ArbiterInfo.inUse() {
-     atomic {
-       if ( state == RES_IDLE )
-         return FALSE;
-     }
      return TRUE;
    }
--- 170,173 ----
***************
*** 206,213 ****
      signal Resource.granted[resId]();
    }
- 
-   task void requestedTask() {
-     signal ResourceController.requested();
-   }
    
    //Default event/command handlers for all of the other
--- 204,207 ----
***************
*** 215,222 ****
      //that have not been connected to.  
    default event void Resource.granted[uint8_t id]() {
!   } 
    default async event void ResourceController.granted() {
    }
!   default event void ResourceController.requested() {
      call ResourceController.release();
    }
--- 209,220 ----
      //that have not been connected to.  
    default event void Resource.granted[uint8_t id]() {
!   }
!   default async event void ResourceRequested.requested[uint8_t id]() {
!   }
!   default async event void ResourceRequested.immediateRequested[uint8_t id]() {
!   }
    default async event void ResourceController.granted() {
    }
!   default async event void ResourceController.requested() {
      call ResourceController.release();
    }



More information about the Tinyos-2-commits mailing list