Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #944 > unrolled thread
| Started by | "Mark" <mark_cruzNOTFORSPAM@hotmail.com> |
|---|---|
| First post | 2011-10-20 19:19 -0400 |
| Last post | 2011-10-21 21:28 -0400 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.programming
weighted-fair queuing "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2011-10-20 19:19 -0400
Re: weighted-fair queuing Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-10-21 00:51 +0100
Re: weighted-fair queuing Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-10-21 02:42 +0100
Re: weighted-fair queuing "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2011-10-21 21:28 -0400
| From | "Mark" <mark_cruzNOTFORSPAM@hotmail.com> |
|---|---|
| Date | 2011-10-20 19:19 -0400 |
| Subject | weighted-fair queuing |
| Message-ID | <j7qaa8$rnh$1@speranza.aioe.org> |
Hello
I'm writing an application for embedded platform, and I need to utilize
weighted-fair queuing scheduling algorithm supported by the target hardware.
So I basically have to assign weight values correctly and commit it in
registers, and here is some confusion.
Weights that can be assigned by user from upper layer software are in range
1-32, the max weight value in h/w is 131072, therefore I need some way to
scale down input value (1-32) to properly fit in the hardware. So I came up
with this simple approach:
#define MAX_WEIGHT_WFQ 131072u
#define QUEUES 8
static inline unsigned int mapweight(int weight)
{
return ((MAX_WEIGHT_WFQ / QUEUES) * weight) / 10;
}
But it's not quite correct, it doesn't allow to fully utilize the available
capacity of weight (131072). Thanks in advance for any comments.
Mark
[toc] | [next] | [standalone]
| From | Rainer Weikusat <rweikusat@mssgmbh.com> |
|---|---|
| Date | 2011-10-21 00:51 +0100 |
| Message-ID | <87fwin1atj.fsf@sapphire.mobileactivedefense.com> |
| In reply to | #944 |
"Mark" <mark_cruzNOTFORSPAM@hotmail.com> writes:
[...]
> Weights that can be assigned by user from upper layer software are in range
> 1-32, the max weight value in h/w is 131072, therefore I need some way to
> scale down input value (1-32) to properly fit in the hardware.
This looks rather as if you would need to scale it up. Given that you
need to map a value in the range (1, 2^5) [2^5 ::= 2 to the fifth
power] to the range (0, 2^17), an obvious idea would be
static inline unsigned map_weight(unsigned weight)
{
return weight * (1 << 12);
}
(since 2^17/2^5 = 2^12, 131072 / 32 = 4096).
[toc] | [prev] | [next] | [standalone]
| From | Rainer Weikusat <rweikusat@mssgmbh.com> |
|---|---|
| Date | 2011-10-21 02:42 +0100 |
| Message-ID | <877h3z15ow.fsf@sapphire.mobileactivedefense.com> |
| In reply to | #945 |
Rainer Weikusat <rweikusat@mssgmbh.com> writes: [...] > return weight * (1 << 12); This is, of course, exactly the same as weight << 12 :-(
[toc] | [prev] | [next] | [standalone]
| From | "Mark" <mark_cruzNOTFORSPAM@hotmail.com> |
|---|---|
| Date | 2011-10-21 21:28 -0400 |
| Message-ID | <j7t80n$p2g$1@speranza.aioe.org> |
| In reply to | #946 |
"Rainer Weikusat" <rweikusat@mssgmbh.com> wrote in message news:877h3z15ow.fsf@sapphire.mobileactivedefense.com... > Rainer Weikusat <rweikusat@mssgmbh.com> writes: > > [...] > > >> return weight * (1 << 12); > > This is, of course, exactly the same as weight << 12 :-( Thank you very much indeed. Mark
[toc] | [prev] | [standalone]
Back to top | Article view | comp.programming
csiph-web