[Tinyos-2-commits] CVS: tinyos-2.x/tos/system ArbiterP.nc, NONE,
1.1.2.1 FcfsResourceQueueC.nc, NONE,
1.1.2.1 RoundRobinResourceQueueC.nc, NONE,
1.1.2.1 SimpleArbiterP.nc, NONE, 1.1.2.1 SimpleFcfsArbiterC.nc,
NONE, 1.1.2.1 SimpleRoundRobinArbiterC.nc, NONE,
1.1.2.1 ArbitratedReadC.nc, 1.1.2.5,
1.1.2.6 ArbitratedReadNowC.nc, 1.1.2.3,
1.1.2.4 ArbitratedReadStreamC.nc, 1.1.2.3,
1.1.2.4 FcfsArbiterC.nc, 1.1.2.13, 1.1.2.14 NoArbiterC.nc,
1.1.2.3, 1.1.2.4 RoundRobinArbiterC.nc, 1.1.2.14,
1.1.2.15 FcfsPriorityArbiterC.nc, 1.1.2.8, NONE
Kevin Klues
klueska at users.sourceforge.net
Tue Aug 15 04:56:09 PDT 2006
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/power
AsyncDeferredPowerManagerP.nc, 1.1.2.3,
1.1.2.4 AsyncPowerManagerP.nc, 1.1.2.4,
1.1.2.5 AsyncStdControlDeferredPowerManagerC.nc, 1.1.2.4,
1.1.2.5 AsyncStdControlPowerManagerC.nc, 1.1.2.5,
1.1.2.6 DeferredPowerManagerP.nc, 1.1.2.5,
1.1.2.6 PowerDownCleanup.nc, 1.1.2.3, 1.1.2.4 PowerManagerP.nc,
1.1.2.4, 1.1.2.5 SplitControlDeferredPowerManagerC.nc, 1.1.2.4,
1.1.2.5 SplitControlPowerManagerC.nc, 1.1.2.4,
1.1.2.5 StdControlDeferredPowerManagerC.nc, 1.1.2.4,
1.1.2.5 StdControlPowerManagerC.nc, 1.1.2.4, 1.1.2.5
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/types Resource.h, NONE,
1.1.2.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/system
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4768/tos/system
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
ArbitratedReadC.nc ArbitratedReadNowC.nc
ArbitratedReadStreamC.nc FcfsArbiterC.nc NoArbiterC.nc
RoundRobinArbiterC.nc
Added Files:
Tag: tinyos-2_0_devel-BRANCH
ArbiterP.nc FcfsResourceQueueC.nc RoundRobinResourceQueueC.nc
SimpleArbiterP.nc SimpleFcfsArbiterC.nc
SimpleRoundRobinArbiterC.nc
Removed Files:
Tag: tinyos-2_0_devel-BRANCH
FcfsPriorityArbiterC.nc
Log Message:
Update to Resource and Power Manager stuff
--- NEW FILE: ArbiterP.nc ---
/*
* Copyright (c) 2004, Technische Universitat Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitat Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Please refer to TEP 108 for more information about this component and its
* intended use.<br><br>
*
* This component provides the Resource, ResourceRequested, ArbiterInfo,
* and ResourceController interfaces and uses the ResourceConfigure interface as
* described in TEP 108. It provides arbitration to a shared resource.
* An Queue is used to keep track of which users have put
* in requests for the resource. Upon the release of the resource by one
* of these users, the queue is checked and the next user
* that has a pending request will ge granted control of the resource. If
* there are no pending requests, then the user of the ResourceController
* interface gains access to the resource, and holds onto it until
* another user makes a request.
*
* @param <b>resourceName</b> -- The name of the Resource being shared
*
* @author Kevin Klues (klues at tkn.tu-berlin.de)
* @author Philip Levis
*/
generic module ArbiterP(uint8_t controller_id) {
provides {
interface Resource[uint8_t id];
interface ResourceRequested[uint8_t id];
interface ResourceController;
interface ArbiterInfo;
}
uses {
interface ResourceConfigure[uint8_t id];
interface ResourceQueue as Queue;
}
}
implementation {
enum {RES_CONTROLLED, RES_GRANTING, RES_IMM_GRANTING, RES_BUSY};
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;
}
else return FAIL;
}
signal ResourceController.immediateRequested();
if(resId == id) {
call ResourceConfigure.configure[resId]();
return SUCCESS;
}
atomic state = RES_CONTROLLED;
return FAIL;
}
async command error_t Resource.release[uint8_t id]() {
bool released = FALSE;
atomic {
if(state == RES_BUSY && resId == id) {
if(call Queue.isEmpty() == FALSE) {
reqResId = call Queue.dequeue();
state = RES_GRANTING;
post grantedTask();
}
else {
resId = CONTROLLER_ID;
state = RES_CONTROLLED;
}
released = TRUE;
}
}
if(released == TRUE) {
call ResourceConfigure.unconfigure[id]();
if(resId == CONTROLLER_ID)
signal ResourceController.granted();
return SUCCESS;
}
return FAIL;
}
async command error_t ResourceController.release() {
atomic {
if(resId == CONTROLLER_ID) {
if(state == RES_GRANTING) {
post grantedTask();
return SUCCESS;
}
else if(state == RES_IMM_GRANTING) {
resId = reqResId;
state = RES_BUSY;
return SUCCESS;
}
}
}
return FAIL;
}
/**
Check if the Resource is currently in use
*/
async command bool ArbiterInfo.inUse() {
return TRUE;
}
/**
Returns the current user of the Resource.
If there is no current user, the return value
will be 0xFF
*/
async command uint8_t ArbiterInfo.userId() {
atomic return resId;
}
/**
* Returns my user id.
*/
async command uint8_t Resource.isOwner[uint8_t id]() {
atomic {
if(resId == id) return TRUE;
else return FALSE;
}
}
async command uint8_t ResourceController.isOwner() {
return call Resource.isOwner[CONTROLLER_ID]();
}
task void grantedTask() {
atomic {
resId = reqResId;
state = RES_BUSY;
}
call ResourceConfigure.configure[resId]();
signal Resource.granted[resId]();
}
//Default event/command handlers for all of the other
//potential users/providers of the parameterized interfaces
//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();
}
default async event void ResourceController.immediateRequested() {
}
default async command void ResourceConfigure.configure[uint8_t id]() {
}
default async command void ResourceConfigure.unconfigure[uint8_t id]() {
}
}
--- NEW FILE: FcfsResourceQueueC.nc ---
/*
* "Copyright (c) 2005 Washington University in St. Louis.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY
* FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
* OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON
* UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
* MODIFICATIONS."
*/
/**
*
* @author Kevin Klues (klueska at cs.wustl.edu)
* @version $Revision: 1.1.2.1 $
* @date $Date: 2006/08/15 11:56:05 $
*/
#include "Resource.h"
generic module FcfsResourceQueueC(uint8_t size) {
provides {
interface Init;
interface ResourceQueue as FcfsQueue;
}
}
implementation {
enum {NO_ENTRY = 0xFF};
uint8_t resQ[size];
uint8_t qHead = NO_ENTRY;
uint8_t qTail = NO_ENTRY;
command error_t Init.init() {
memset(resQ, NO_ENTRY, sizeof(resQ));
return SUCCESS;
}
async command bool FcfsQueue.isEmpty() {
return (qHead == NO_ENTRY);
}
async command bool FcfsQueue.isEnqueued(resource_client_id_t id) {
return resQ[id] != NO_ENTRY || qTail == id;
}
async command resource_client_id_t FcfsQueue.dequeue() {
atomic {
if(qHead != NO_ENTRY) {
uint8_t id = qHead;
qHead = resQ[qHead];
if(qHead == NO_ENTRY)
qTail = NO_ENTRY;
resQ[id] = NO_ENTRY;
return id;
}
return NO_ENTRY;
}
}
async command error_t FcfsQueue.enqueue(resource_client_id_t id) {
atomic {
if(!(call FcfsQueue.isEnqueued(id))) {
if(qHead == NO_ENTRY)
qHead = id;
else
resQ[qTail] = id;
qTail = id;
return SUCCESS;
}
return EBUSY;
}
}
}
--- NEW FILE: RoundRobinResourceQueueC.nc ---
/*
* "Copyright (c) 2005 Washington University in St. Louis.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY
* FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
* OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON
* UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
* MODIFICATIONS."
*/
/**
*
* @author Kevin Klues (klueska at cs.wustl.edu)
* @version $Revision: 1.1.2.1 $
* @date $Date: 2006/08/15 11:56:05 $
*/
#include "Resource.h"
generic module RoundRobinResourceQueueC(uint8_t size) {
provides {
interface Init;
interface ResourceQueue as RoundRobinQueue;
}
}
implementation {
enum {NO_ENTRY = 0xFF};
uint8_t resQ[(size-1)/8 + 1];
uint8_t last = 0;
void clearEntry(uint8_t id) {
resQ[id / 8] &= ~(1 << (id % 8));
}
command error_t Init.init() {
memset(resQ, NO_ENTRY, sizeof(resQ));
return SUCCESS;
}
async command bool RoundRobinQueue.isEmpty() {
int i;
atomic {
for (i = 0; i<sizeof(resQ); i++)
if(resQ[i] > 0) return FALSE;
return TRUE;
}
}
async command bool RoundRobinQueue.isEnqueued(resource_client_id_t id) {
return resQ[id / 8] & (1 << (id % 8));
}
async command resource_client_id_t RoundRobinQueue.dequeue() {
int i;
atomic {
for (i = last+1; ; i++) {
if(i == size)
i = 0;
if (i == last)
break;
if (call RoundRobinQueue.isEnqueued(i)) {
clearEntry(i);
last = i;
return i;
}
}
return NO_ENTRY;
}
}
async command error_t RoundRobinQueue.enqueue(resource_client_id_t id) {
atomic {
if (!(call RoundRobinQueue.isEnqueued(id))) {
resQ[id / 8] |= 1 << (id % 8);
return SUCCESS;
}
return EBUSY;
}
}
}
--- NEW FILE: SimpleArbiterP.nc ---
/*
* Copyright (c) 2004, Technische Universitat Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitat Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Please refer to TEP 108 for more information about this component and its
* intended use.<br><br>
*
* This component provides the Resource, ArbiterInfo, and ResourceRequested
* interfaces and uses the ResourceConfigure interface as
* described in TEP 108. It provides arbitration to a shared resource.
* An queue is used to keep track of which users have put
* in requests for the resource. Upon the release of the resource by one
* of these users, the queue is checked and the next user
* that has a pending request will ge granted control of the resource. If
* there are no pending requests, then the resource becomes idle and any
* user can put in a request and immediately receive access to the
* Resource.
*
* @param <b>resourceName</b> -- The name of the Resource being shared
*
* @author Kevin Klues (klues at tkn.tu-berlin.de)
* @author Philip Levis
*/
generic module SimpleArbiterP() {
provides {
interface Resource[uint8_t id];
interface ResourceRequested[uint8_t id];
interface ArbiterInfo;
}
uses {
interface ResourceConfigure[uint8_t id];
interface ResourceQueue as Queue;
}
}
implementation {
enum {RES_IDLE = 0, RES_GRANTING = 1, RES_BUSY = 2};
enum {NO_RES = 0xFF};
uint8_t state = RES_IDLE;
norace uint8_t resId = NO_RES;
norace uint8_t reqResId;
task void grantedTask();
async command error_t Resource.request[uint8_t id]() {
signal ResourceRequested.requested[resId]();
atomic {
if(state == RES_IDLE) {
state = RES_GRANTING;
reqResId = id;
post grantedTask();
return SUCCESS;
}
return call Queue.enqueue(id);
}
}
async command error_t Resource.immediateRequest[uint8_t id]() {
signal ResourceRequested.immediateRequested[resId]();
atomic {
if(state == RES_IDLE) {
state = RES_BUSY;
resId = id;
call ResourceConfigure.configure[resId]();
return SUCCESS;
}
return FAIL;
}
}
async command error_t Resource.release[uint8_t id]() {
bool released = FALSE;
atomic {
if(state == RES_BUSY && resId == id) {
if(call Queue.isEmpty() == FALSE) {
reqResId = call Queue.dequeue();
state = RES_GRANTING;
post grantedTask();
}
else {
resId = NO_RES;
state = RES_IDLE;
}
released = TRUE;
}
}
if(released == TRUE) {
call ResourceConfigure.unconfigure[id]();
return SUCCESS;
}
return FAIL;
}
/**
Check if the Resource is currently in use
*/
async command bool ArbiterInfo.inUse() {
atomic {
if (state == RES_IDLE)
return FALSE;
}
return TRUE;
}
/**
Returns the current user of the Resource.
If there is no current user, the return value
will be 0xFF
*/
async command uint8_t ArbiterInfo.userId() {
atomic return resId;
}
/**
* Returns whether you are the current owner of the resource or not
*/
async command uint8_t Resource.isOwner[uint8_t id]() {
atomic {
if(resId == id) return TRUE;
else return FALSE;
}
}
task void grantedTask() {
atomic {
resId = reqResId;
state = RES_BUSY;
}
call ResourceConfigure.configure[resId]();
signal Resource.granted[resId]();
}
//Default event/command handlers
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 command void ResourceConfigure.configure[uint8_t id]() {
}
default async command void ResourceConfigure.unconfigure[uint8_t id]() {
}
}
--- NEW FILE: SimpleFcfsArbiterC.nc ---
/*
* "Copyright (c) 2005 Washington University in St. Louis.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY
* FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
* OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON
* UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
* MODIFICATIONS."
*/
/*
* Copyright (c) 2004, Technische Universitat Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitat Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Please refer to TEP 108 for more information about this component and its
* intended use.<br><br>
*
* This component provides the Resource, ArbiterInfo, and Resource
* Controller interfaces and uses the ResourceConfigure interface as
* described in TEP 108. It provides arbitration to a shared resource in
* an FCFS fashion. An array is used to keep track of which users have put
* in requests for the resource. Upon the release of the resource by one
* of these users, the array is checked and the next user (in FCFS order)
* that has a pending request will ge granted control of the resource. If
* there are no pending requests, then the resource becomes idle and any
* user can put in a request and immediately receive access to the
* Resource.
*
* @param <b>resourceName</b> -- The name of the Resource being shared
*
* @author Kevin Klues (klues at tkn.tu-berlin.de)
* @author Philip Levis
*/
generic configuration SimpleFcfsArbiterC(char resourceName[]) {
provides {
interface Resource[uint8_t id];
interface ResourceRequested[uint8_t id];
interface ArbiterInfo;
}
uses interface ResourceConfigure[uint8_t id];
}
implementation {
components MainC;
components new FcfsResourceQueueC(uniqueCount(resourceName)) as Queue;
components new SimpleArbiterP() as Arbiter;
MainC.SoftwareInit -> Queue;
Resource = Arbiter;
ResourceRequested = Arbiter;
ArbiterInfo = Arbiter;
ResourceConfigure = Arbiter;
Arbiter.Queue -> Queue;
}
--- NEW FILE: SimpleRoundRobinArbiterC.nc ---
/*
* "Copyright (c) 2005 Washington University in St. Louis.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY
* FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
* OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON
* UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
* MODIFICATIONS."
*/
/*
* Copyright (c) 2004, Technische Universitat Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitat Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Please refer to TEP 108 for more information about this component and its
* intended use.<br><br>
*
* This component provides the Resource, ArbiterInfo, and Resource
* Controller interfaces and uses the ResourceConfigure interface as
* described in TEP 108. It provides arbitration to a shared resource in
* an FCFS fashion. An array is used to keep track of which users have put
* in requests for the resource. Upon the release of the resource by one
* of these users, the array is checked and the next user (in FCFS order)
* that has a pending request will ge granted control of the resource. If
* there are no pending requests, then the resource becomes idle and any
* user can put in a request and immediately receive access to the
* Resource.
*
* @param <b>resourceName</b> -- The name of the Resource being shared
*
* @author Kevin Klues (klues at tkn.tu-berlin.de)
* @author Philip Levis
*/
generic configuration SimpleRoundRobinArbiterC(char resourceName[]) {
provides {
interface Resource[uint8_t id];
interface ResourceRequested[uint8_t id];
interface ArbiterInfo;
}
uses interface ResourceConfigure[uint8_t id];
}
implementation {
components MainC;
components new RoundRobinResourceQueueC(uniqueCount(resourceName)) as Queue;
components new SimpleArbiterP() as Arbiter;
MainC.SoftwareInit -> Queue;
Resource = Arbiter;
ResourceRequested = Arbiter;
ArbiterInfo = Arbiter;
ResourceConfigure = Arbiter;
Arbiter.Queue -> Queue;
}
Index: ArbitratedReadC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/system/ArbitratedReadC.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
*** ArbitratedReadC.nc 16 Feb 2006 18:26:16 -0000 1.1.2.5
--- ArbitratedReadC.nc 15 Aug 2006 11:56:05 -0000 1.1.2.6
***************
*** 50,54 ****
return FAIL;
}
! default async command void Resource.release[uint8_t client]() { }
default event void Read.readDone[uint8_t client](error_t result, width_t data) { }
default command error_t Service.read[uint8_t client]() {
--- 50,54 ----
return FAIL;
}
! default async command error_t Resource.release[uint8_t client]() { return FAIL; }
default event void Read.readDone[uint8_t client](error_t result, width_t data) { }
default command error_t Service.read[uint8_t client]() {
Index: ArbitratedReadNowC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/system/ArbitratedReadNowC.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** ArbitratedReadNowC.nc 27 Jan 2006 22:19:17 -0000 1.1.2.3
--- ArbitratedReadNowC.nc 15 Aug 2006 11:56:05 -0000 1.1.2.4
***************
*** 46,50 ****
return FAIL;
}
! default async command void Resource.release[uint8_t client]() { }
default async event void ReadNow.readDone[uint8_t client](error_t result, width_t data) { }
default async command error_t Service.read[uint8_t client]() {
--- 46,50 ----
return FAIL;
}
! default async command error_t Resource.release[uint8_t client]() { return FAIL; }
default async event void ReadNow.readDone[uint8_t client](error_t result, width_t data) { }
default async command error_t Service.read[uint8_t client]() {
Index: ArbitratedReadStreamC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/system/ArbitratedReadStreamC.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** ArbitratedReadStreamC.nc 17 Feb 2006 00:26:48 -0000 1.1.2.3
--- ArbitratedReadStreamC.nc 15 Aug 2006 11:56:05 -0000 1.1.2.4
***************
*** 65,69 ****
return SUCCESS;
}
! default async command void Resource.release[uint8_t client]() { }
default command error_t Service.postBuffer[uint8_t client](val_t* buf, uint16_t count)
--- 65,69 ----
return SUCCESS;
}
! default async command error_t Resource.release[uint8_t client]() { return FAIL; }
default command error_t Service.postBuffer[uint8_t client](val_t* buf, uint16_t count)
Index: FcfsArbiterC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/system/FcfsArbiterC.nc,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -C2 -d -r1.1.2.13 -r1.1.2.14
*** FcfsArbiterC.nc 25 Apr 2006 23:45:21 -0000 1.1.2.13
--- FcfsArbiterC.nc 15 Aug 2006 11:56:05 -0000 1.1.2.14
***************
*** 75,341 ****
*
* @author Kevin Klues (klues at tkn.tu-berlin.de)
- * @author Philip Levis
*/
! generic module FcfsArbiterC(char resourceName[]) {
provides {
- interface Init;
interface Resource[uint8_t id];
interface ResourceController;
interface ArbiterInfo;
}
! uses {
! interface ResourceConfigure[uint8_t id];
! }
}
implementation {
! enum {RES_IDLE, RES_GRANTING, RES_BUSY};
! enum {NO_RES = 0xFF};
! enum {CONTROLLER_ID = uniqueCount(resourceName) + 1};
!
! uint8_t state = RES_IDLE;
! uint8_t resId = NO_RES;
! uint8_t reqResId = NO_RES;
! uint8_t resQ[uniqueCount(resourceName)];
! uint8_t qHead = NO_RES;
! uint8_t qTail = NO_RES;
! bool irp = FALSE;
!
! task void grantedTask();
! task void requestedTask();
! error_t queueRequest(uint8_t id);
! void grantNextRequest();
!
! bool requested(uint8_t id) {
! return resQ[id] != NO_RES || qTail == id;
! }
!
! /**
! Initialize the Arbiter to the idle state
! */
! command error_t Init.init() {
! memset( resQ, NO_RES, sizeof( resQ ) );
! return SUCCESS;
! }
!
! /**
! 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 in an FCFS fashion.
! 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 ) {
! state = RES_GRANTING;
! reqResId = id;
! post grantedTask();
! return SUCCESS;
! }
! if(resId == CONTROLLER_ID)
! post requestedTask();
! return queueRequest( id );
! }
! }
!
! async command error_t ResourceController.request() {
! return call Resource.request[CONTROLLER_ID]();
! }
!
! /**
! * Request immediate access to the shared resource. Requests are
! * not queued, and no granted event is returned. A return value
! * of SUCCESS signifies that the resource has been granted to you,
! * while a return value of EBUSY signifies that the resource is
! * currently being used.
! */
! uint8_t tryImmediateRequest(uint8_t id) {
! atomic {
! if( state == RES_IDLE ) {
! state = RES_BUSY;
! resId = id;
! return id;
! }
! return resId;
! }
! }
! async command error_t Resource.immediateRequest[uint8_t id]() {
! uint8_t ownerId = tryImmediateRequest(id);
!
! if(ownerId == id) {
! call ResourceConfigure.configure[id]();
! return SUCCESS;
! }
! else if(ownerId == CONTROLLER_ID){
! atomic {
! irp = TRUE; //indicate that immediateRequest is pending
! reqResId = id; //Id to grant resource to if can
! }
! signal ResourceController.requested();
! atomic {
! ownerId = resId; //See if I have been granted the resource
! irp = FALSE; //Indicate that immediate request no longer pending
! }
! if(ownerId == id) {
! call ResourceConfigure.configure[id]();
! return SUCCESS;
! }
! return EBUSY;
! }
! else return EBUSY;
! }
! async command error_t ResourceController.immediateRequest() {
! return call Resource.immediateRequest[CONTROLLER_ID]();
! }
!
! /**
! Release the use of the shared resource
!
! The resource will only actually be released if
! there are no pending requests for the resource.
! If requests are pending, then the next pending request
! will be serviced, according to a Fist come first serve
! arbitration scheme. If no requests are currently
! pending, then the resource is released, and any
! users can put in a request for immediate access to
! the resource.
! */
! async command void Resource.release[uint8_t id]() {
! uint8_t currentState;
! atomic {
! if (state == RES_BUSY && resId == id) {
! if (irp)
! resId = reqResId;
! else grantNextRequest();
! call ResourceConfigure.unconfigure[id]();
! }
! currentState = state;
! }
! if(currentState == RES_IDLE)
! signal ResourceController.idle();
! }
! async command void ResourceController.release() {
! call Resource.release[CONTROLLER_ID]();
! }
!
! /**
! Check if the Resource is currently in use
! */
! async command bool ArbiterInfo.inUse() {
! atomic {
! if ( state == RES_IDLE )
! return FALSE;
! }
! return TRUE;
! }
!
! /**
! Returns the current user of the Resource.
! If there is no current user, the return value
! will be 0xFF
! */
! async command uint8_t ArbiterInfo.userId() {
! atomic return resId;
! }
! /**
! * Returns my user id.
! */
! async command uint8_t Resource.isOwner[uint8_t id]() {
! atomic {
! if(resId == id) return TRUE;
! else return FALSE;
! }
! }
! async command uint8_t ResourceController.isOwner() {
! return call Resource.isOwner[CONTROLLER_ID]();
! }
!
! //Grant a request to the next Pending user
! //in FCFS order
! void grantNextRequest() {
! resId = NO_RES;
! if(qHead != NO_RES) {
! uint8_t id = qHead;
! qHead = resQ[qHead];
! if(qHead == NO_RES)
! qTail = NO_RES;
! resQ[id] = NO_RES;
! reqResId = id;
! state = RES_GRANTING;
! post grantedTask();
! }
! else {
! state = RES_IDLE;
! }
! }
!
! //Queue the requests so that they can be granted
! //in FCFS order after release of the resource
! error_t queueRequest(uint8_t id) {
! atomic {
! if( !requested( id ) ) {
! if(qHead == NO_RES )
! qHead = id;
! else
! resQ[qTail] = id;
! qTail = id;
! return SUCCESS;
! }
! return EBUSY;
! }
! }
!
! //Task for pulling the Resource.granted() signal
! //into synchronous context
! task void grantedTask() {
! uint8_t tmpId;
! atomic {
! tmpId = resId = reqResId;
! state = RES_BUSY;
! }
! call ResourceConfigure.configure[tmpId]();
! signal Resource.granted[tmpId]();
! }
! //Task for pulling the ResourceController.requested() signal
! //into synchronous context
! task void requestedTask() {
! uint8_t tmpId;
! atomic {
! tmpId = resId;
! }
! if(tmpId == CONTROLLER_ID)
! signal ResourceController.requested();
! }
!
! //Default event/command handlers for all of the other
! //potential users/providers of the parameterized interfaces
! //that have not been connected to.
! default event void Resource.granted[uint8_t id]() {
! signal ResourceController.granted();
! }
! default event void ResourceController.granted() {
! }
! default async event void ResourceController.requested() {
! }
! default async event void ResourceController.idle() {
! }
! default async command void ResourceConfigure.configure[uint8_t id]() {
! }
! default async command void ResourceConfigure.unconfigure[uint8_t id]() {
! }
}
--- 75,102 ----
*
* @author Kevin Klues (klues at tkn.tu-berlin.de)
*/
! generic configuration FcfsArbiterC(char resourceName[]) {
provides {
interface Resource[uint8_t id];
+ interface ResourceRequested[uint8_t id];
interface ResourceController;
interface ArbiterInfo;
}
! uses interface ResourceConfigure[uint8_t id];
}
implementation {
+ components MainC;
+ components new FcfsResourceQueueC(uniqueCount(resourceName)) as Queue;
+ components new ArbiterP(uniqueCount(resourceName)) as Arbiter;
! MainC.SoftwareInit -> Queue;
! Resource = Arbiter;
! ResourceRequested = Arbiter;
! ResourceController = Arbiter;
! ArbiterInfo = Arbiter;
! ResourceConfigure = Arbiter;
! Arbiter.Queue -> Queue;
}
Index: NoArbiterC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/system/NoArbiterC.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** NoArbiterC.nc 8 Mar 2006 02:12:22 -0000 1.1.2.3
--- NoArbiterC.nc 15 Aug 2006 11:56:05 -0000 1.1.2.4
***************
*** 15,18 ****
--- 15,19 ----
*
* @author David Gay
+ * @author Kevin Klues
*/
***************
*** 37,42 ****
}
! async command void Resource.release() {
call ResourceConfigure.unconfigure();
}
--- 38,44 ----
}
! async command error_t Resource.release() {
call ResourceConfigure.unconfigure();
+ return SUCCESS;
}
Index: RoundRobinArbiterC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/system/RoundRobinArbiterC.nc,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -C2 -d -r1.1.2.14 -r1.1.2.15
*** RoundRobinArbiterC.nc 25 Apr 2006 23:45:33 -0000 1.1.2.14
--- RoundRobinArbiterC.nc 15 Aug 2006 11:56:05 -0000 1.1.2.15
***************
*** 63,337 ****
* This component provides the Resource, ArbiterInfo, and Resource
* Controller interfaces and uses the ResourceConfigure interface as
! * described in TEP 108. It provides arbitration to a shared resource in a
! * round robin fashion. An array is used to keep track of which users have
! * put in requests for the resource. Upon the release of the resource by
! * one of these users, the array is checked and the next user (in round
! * robin order) that has a pending request will ge granted control of the
! * resource. If there are no pending requests, then the resource becomes
! * idle and any user can put in a request and immediately receive access to
! * the round robin order * Resource.
*
* @param <b>resourceName</b> -- The name of the Resource being shared
*
* @author Kevin Klues (klues at tkn.tu-berlin.de)
- * @author Philip Levis
*/
! generic module RoundRobinArbiterC(char resourceName[]) {
provides {
- interface Init @atleastonce();
interface Resource[uint8_t id];
interface ResourceController;
interface ArbiterInfo;
}
! uses {
! interface ResourceConfigure[uint8_t id];
! }
}
implementation {
! enum {RES_IDLE, RES_GRANTING, RES_BUSY};
! enum {NO_RES = 0xFF};
! enum {CONTROLLER_ID = uniqueCount(resourceName) + 1};
!
! uint8_t state = RES_IDLE;
! uint8_t resId = NO_RES;
! uint8_t reqResId;
! uint8_t request[(uniqueCount(resourceName)-1)/8 + 1];
! bool irp = FALSE;
!
! task void grantedTask();
! task void requestedTask();
! void grantNextRequest();
!
! /**
! Initialize the Arbiter to the idle state
! */
! command error_t Init.init() {
! return SUCCESS;
! }
!
! uint8_t requested(uint8_t id) {
! return request[id / 8] & (1 << (id % 8));
! }
!
! void clearRequest(uint8_t id) {
! request[id / 8] &= ~(1 << (id % 8));
! }
!
! error_t queueRequest(uint8_t id) {
! if (!requested(id)){
! request[id / 8] |= 1 << (id % 8);
! return SUCCESS;
! }
! return EBUSY;
! }
!
! /**
! 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 in a round robin fashion.
! 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 ) {
! state = RES_GRANTING;
! reqResId = id;
! post grantedTask();
! return SUCCESS;
! }
! if(resId == CONTROLLER_ID)
! post requestedTask();
! return queueRequest( id );
! }
! }
!
! async command error_t ResourceController.request() {
! return call Resource.request[CONTROLLER_ID]();
! }
!
! /**
! * Request immediate access to the shared resource. Requests are
! * not queued, and no granted event is returned. A return value
! * of SUCCESS signifies that the resource has been granted to you,
! * while a return value of EBUSY signifies that the resource is
! * currently being used.
! */
! uint8_t tryImmediateRequest(uint8_t id) {
! atomic {
! if( state == RES_IDLE ) {
! state = RES_BUSY;
! resId = id;
! return id;
! }
! return resId;
! }
! }
! async command error_t Resource.immediateRequest[uint8_t id]() {
! uint8_t ownerId = tryImmediateRequest(id);
!
! if(ownerId == id) {
! call ResourceConfigure.configure[id]();
! return SUCCESS;
! }
! else if(ownerId == CONTROLLER_ID){
! atomic {
! irp = TRUE; //indicate that immediateRequest is pending
! reqResId = id; //Id to grant resource to if can
! }
! signal ResourceController.requested();
! atomic {
! ownerId = resId; //See if I have been granted the resource
! irp = FALSE; //Indicate that immediate request no longer pending
! }
! if(ownerId == id) {
! call ResourceConfigure.configure[id]();
! return SUCCESS;
! }
! return EBUSY;
! }
! else return EBUSY;
! }
!
! async command error_t ResourceController.immediateRequest() {
! return call Resource.immediateRequest[CONTROLLER_ID]();
! }
!
! /**
! Release the use of the shared resource
!
! The resource will only actually be released if
! there are no pending requests for the resource.
! If requests are pending, then the next pending request
! will be serviced, according to a round robin arbitration
! scheme. If no requests are currently pending, then the
! resource is released, and any users can put in a request
! for immediate access to the resource.
! */
! async command void Resource.release[uint8_t id]() {
! uint8_t currentState;
! atomic {
! if (state == RES_BUSY && resId == id) {
! if(irp)
! resId = reqResId;
! else grantNextRequest();
! call ResourceConfigure.unconfigure[id]();
! }
! currentState = state;
! }
! if(currentState == RES_IDLE)
! signal ResourceController.idle();
! }
!
! async command void ResourceController.release() {
! call Resource.release[CONTROLLER_ID]();
! }
!
! /**
! Check if the Resource is currently in use
! */
! async command bool ArbiterInfo.inUse() {
! atomic {
! if ( state == RES_IDLE )
! return FALSE;
! }
! return TRUE;
! }
! /**
! Returns the current user of the Resource.
! If there is no current user, the return value
! will be 0xFF
! */
! async command uint8_t ArbiterInfo.userId() {
! atomic return resId;
! }
! /**
! * Returns my user id.
! */
! async command uint8_t Resource.isOwner[uint8_t id]() {
! atomic {
! if(resId == id) return TRUE;
! else return FALSE;
! }
! }
! async command uint8_t ResourceController.isOwner() {
! return call Resource.isOwner[CONTROLLER_ID]();
! }
!
! //Grant a request to the next Pending user
! //in Round-Robin order
! void grantNextRequest() {
! int i;
!
! for (i = resId + 1; ; i++) {
! if (i >= (uniqueCount(resourceName) + 1))
! i = 0;
! if (i == resId)
! break;
! if (requested(i)) {
! reqResId = i;
! clearRequest(i);
! resId = NO_RES;
! state = RES_GRANTING;
! post grantedTask();
! return;
! }
! }
! resId = NO_RES;
! state = RES_IDLE;
! }
!
! //Task for pulling the Resource.granted() signal
! //into synchronous context
! task void grantedTask() {
! uint8_t tmpId;
! atomic {
! tmpId = resId = reqResId;
! state = RES_BUSY;
! }
! call ResourceConfigure.configure[tmpId]();
! signal Resource.granted[tmpId]();
! }
! //Task for pulling the ResourceController.requested() signal
! //into synchronous context
! task void requestedTask() {
! uint8_t tmpId;
! atomic {
! tmpId = resId;
! }
! if(tmpId == CONTROLLER_ID)
! signal ResourceController.requested();
! }
!
! //Default event/command handlers for all of the other
! //potential users/providers of the parameterized interfaces
! //that have not been connected to.
! default event void Resource.granted[uint8_t id]() {
! signal ResourceController.granted();
! }
! default event void ResourceController.granted() {
! }
! default async event void ResourceController.requested() {
! }
! default async event void ResourceController.idle() {
! }
! default async command void ResourceConfigure.configure[uint8_t id]() {
! }
! default async command void ResourceConfigure.unconfigure[uint8_t id]() {
! }
}
--- 63,102 ----
* This component provides the Resource, ArbiterInfo, and Resource
* Controller interfaces and uses the ResourceConfigure interface as
! * described in TEP 108. It provides arbitration to a shared resource in
! * an FCFS fashion. An array is used to keep track of which users have put
! * in requests for the resource. Upon the release of the resource by one
! * of these users, the array is checked and the next user (in FCFS order)
! * that has a pending request will ge granted control of the resource. If
! * there are no pending requests, then the resource becomes idle and any
! * user can put in a request and immediately receive access to the
! * Resource.
*
* @param <b>resourceName</b> -- The name of the Resource being shared
*
* @author Kevin Klues (klues at tkn.tu-berlin.de)
*/
! generic configuration RoundRobinArbiterC(char resourceName[]) {
provides {
interface Resource[uint8_t id];
+ interface ResourceRequested[uint8_t id];
interface ResourceController;
interface ArbiterInfo;
}
! uses interface ResourceConfigure[uint8_t id];
}
implementation {
! components MainC;
! components new RoundRobinResourceQueueC(uniqueCount(resourceName)) as Queue;
! components new ArbiterP(uniqueCount(resourceName)) as Arbiter;
! MainC.SoftwareInit -> Queue;
! Resource = Arbiter;
! ResourceRequested = Arbiter;
! ResourceController = Arbiter;
! ArbiterInfo = Arbiter;
! ResourceConfigure = Arbiter;
! Arbiter.Queue -> Queue;
}
--- FcfsPriorityArbiterC.nc DELETED ---
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/power
AsyncDeferredPowerManagerP.nc, 1.1.2.3,
1.1.2.4 AsyncPowerManagerP.nc, 1.1.2.4,
1.1.2.5 AsyncStdControlDeferredPowerManagerC.nc, 1.1.2.4,
1.1.2.5 AsyncStdControlPowerManagerC.nc, 1.1.2.5,
1.1.2.6 DeferredPowerManagerP.nc, 1.1.2.5,
1.1.2.6 PowerDownCleanup.nc, 1.1.2.3, 1.1.2.4 PowerManagerP.nc,
1.1.2.4, 1.1.2.5 SplitControlDeferredPowerManagerC.nc, 1.1.2.4,
1.1.2.5 SplitControlPowerManagerC.nc, 1.1.2.4,
1.1.2.5 StdControlDeferredPowerManagerC.nc, 1.1.2.4,
1.1.2.5 StdControlPowerManagerC.nc, 1.1.2.4, 1.1.2.5
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/types Resource.h, NONE,
1.1.2.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list