[bwm-tools-devel] COMMIT - r52 - trunk/bwmd
Brought to you by:
nkukard
From: SVN C. <sv...@li...> - 2005-01-21 06:38:53
|
Author: nkukard Date: 2005-01-21 08:38:35 +0200 (Fri, 21 Jan 2005) New Revision: 52 Modified: trunk/bwmd/flow.c Log: * Improved the way avergare throughput is calculated over time * Improved packet processing efficiency Modified: trunk/bwmd/flow.c =================================================================== --- trunk/bwmd/flow.c 2005-01-19 18:26:32 UTC (rev 51) +++ trunk/bwmd/flow.c 2005-01-21 06:38:35 UTC (rev 52) @@ -321,8 +321,26 @@ // 2 seconds if (flow->curThroughputAge >= 2000000) { - flow->curThroughputAge -= 2000000; - flow->curThroughput = flow->curThroughputAge / 1000000.0 * flow->curThroughput; + float delta; + + // flow->curThroughputAge -= 2000000; + + // Get the fraction of time passed since last update + delta = flow->curThroughputAge / 1000000.0; + + // Calculate throughput + flow->curThroughput /= delta; + + // Calculate average queue size + flow->avgQueueSize = (flow->avgQueueSize + flow->curQueueSize) / delta; + /* + fprintf(stderr,"%s: curThroughput: %f, avgQueueSize: %li, delta: %f\n", + flow->flowName, + flow->curThroughput, + flow->avgQueueSize, + delta); + */ + flow->curThroughputAge = 0; } // Set this as the last time we updated our throughput @@ -446,9 +464,6 @@ void *flowRunner(void *data) { struct runnerData_t *runnerData = (struct runnerData_t*) data; - GList *queueChangeList[NUM_PRIO_BANDS]; - int i, pktsProcessed = 0; - GTimeVal mytime; // Our processing function @@ -459,19 +474,21 @@ // Check if we found a flow with a queue - pktsProcessed += processPktQueue(aRunnerData,pktQueue); + // NOTE: The function below returns the number of packets processed + processPktQueue(aRunnerData,pktQueue); } - // Allocate queue change list - for (i = 0; i < NUM_PRIO_BANDS; i++) - queueChangeList[i] = NULL; - logMessage(LOG_DEBUG, "Flow runner started...\n"); // Loop when we get a signal while (1) { + GTimeVal mytime; + unsigned char i; + GList *queueChangeList = NULL; + + g_mutex_lock(runnerData->bandSignalLock); // If the queue has changed proceed @@ -486,15 +503,14 @@ // Hijack the queue change list items for (i = 0; i < NUM_PRIO_BANDS; i++) { - // Copy list item over - queueChangeList[i] = runnerData->queueChangeList[i]; // Zero runner data if it is non-NULL if (runnerData->queueChangeList[i]) { - runnerData->queueChangeList[i] = NULL; + // Copy list item over + queueChangeList = g_list_concat(queueChangeList,runnerData->queueChangeList[i]); + // Blank used list... copy uses directly + runnerData->queueChangeList[i] = NULL; } - else - queueChangeList[i] = NULL; } runnerData->queueChanged = 0; @@ -502,15 +518,11 @@ g_mutex_unlock(runnerData->bandSignalLock); - // Process all list - for (i = 0; i < NUM_PRIO_BANDS; i++) + // Process list if it is non-NULL + if (queueChangeList) { - // Process list if it is non-NULL - if (queueChangeList[i]) - { - g_list_foreach(queueChangeList[i],processQueue,runnerData); - g_list_free(queueChangeList[i]); - } + g_list_foreach(queueChangeList,processQueue,runnerData); + g_list_free(queueChangeList); } } |