Changeset 93632 in vbox for trunk/src/VBox
- Timestamp:
- Feb 7, 2022 1:15:44 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PDMAllNetShaper.cpp
r93631 r93632 27 27 #include <VBox/log.h> 28 28 #include <iprt/time.h> 29 #include <iprt/asm-math.h> 29 30 30 31 … … 59 60 /* 60 61 * Re-fill the bucket first 62 * 63 * Note! We limit the cTokensAdded calculation to 1 second, since it's really 64 * pointless to calculate much beyond PDM_NETSHAPER_MAX_LATENCY (100ms) 65 * let alone 1 sec. This makes it possible to use ASMMultU64ByU32DivByU32 66 * as the cNsDelta is less than 30 bits wide now, which means we don't get 67 * into overflow issues when multiplying two 64-bit values. 61 68 */ 62 uint64_t const nsNow = RTTimeSystemNanoTS(); 63 uint64_t const cNsDelta = nsNow - pGroup->tsUpdatedLast; 64 /** @todo r=bird: there might be an overflow issue here if the gap 65 * between two transfers is too large. */ 66 uint32_t cTokensAdded = cNsDelta * cbPerSecMax / RT_NS_1SEC; 67 69 uint64_t const nsNow = RTTimeSystemNanoTS(); 70 uint64_t const cNsDelta = nsNow - pGroup->tsUpdatedLast; 71 uint64_t const cTokensAdded = cNsDelta < RT_NS_1SEC 72 ? ASMMultU64ByU32DivByU32(cbPerSecMax, (uint32_t)cNsDelta, RT_NS_1SEC) 73 : cbPerSecMax; 68 74 uint32_t const cbBucket = pGroup->cbBucket; 69 75 uint32_t const cbTokensLast = pGroup->cbTokensLast; 70 uint32_t const cTokens = RT_MIN(cbBucket, cTokensAdded + cbTokensLast);76 uint32_t const cTokens = (uint32_t)RT_MIN(cbBucket, cTokensAdded + cbTokensLast); 71 77 72 78 /*
Note:
See TracChangeset
for help on using the changeset viewer.