X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fsystem%2FPoolP.nc;h=9011d6cfd273898c93c904d0fde6c6a4e3fffd1f;hb=2209f8d2cb9ae1b6c268532e99a374533eb8fa78;hp=960b03baea14a18373b17a647a3be8d86d122161;hpb=1ba974b83d19fc41bf80acd52726f36f7f1df297;p=tinyos-2.x.git diff --git a/tos/system/PoolP.nc b/tos/system/PoolP.nc index 960b03ba..9011d6cf 100644 --- a/tos/system/PoolP.nc +++ b/tos/system/PoolP.nc @@ -46,6 +46,7 @@ * * @author Philip Levis * @author Kyle Jamieson + * @author Geoffrey Mainland * @date $Date$ */ @@ -58,7 +59,7 @@ generic module PoolP(typedef pool_t, uint8_t size) { implementation { uint8_t free; uint8_t index; - pool_t* queue[size]; + pool_t* ONE_NOK queue[size]; pool_t pool[size]; command error_t Init.init() { @@ -72,9 +73,11 @@ implementation { } command bool Pool.empty() { + dbg("PoolP", "%s size is %i\n", __FUNCTION__, (int)free); return free == 0; } command uint8_t Pool.size() { + dbg("PoolP", "%s size is %i\n", __FUNCTION__, (int)free); return free; } @@ -87,7 +90,11 @@ implementation { pool_t* rval = queue[index]; queue[index] = NULL; free--; - index = (index + 1) % size; + index++; + if (index == size) { + index = 0; + } + dbg("PoolP", "%s size is %i\n", __FUNCTION__, (int)free); return rval; } return NULL; @@ -98,9 +105,13 @@ implementation { return FAIL; } else { - uint8_t emptyIndex = (index + free) % size; + uint16_t emptyIndex = (index + free); + if (emptyIndex >= size) { + emptyIndex -= size; + } queue[emptyIndex] = newVal; free++; + dbg("PoolP", "%s size is %i\n", __FUNCTION__, (int)free); return SUCCESS; } }