Questions about allocations
Posted: 09-19-2003, 07:10 AM
a queue of packets, some of which may be delayed before being sent. My
question is two-fold. I'm not entirely sure the Passthru example is the way
I should go, but from my limited reading so far, it seems the best choice.
Essentially, what I want to do is slow down certain types of packets. So I
need to maintain a queue of packets that are to be sent (or received) and
will add packets to the queue as necessary.
Now, I can make the queue a static length of, say 50 packets, and I doubt I
would run into problems. On the other hand, I hate having fixed length
arrays because it either wastes memory or potentially causes problems if you
overflow.
What sort of penalty would I be incurring by periodically resizing the
array, when necessary? Keep in mind that if I resize the array, all the
packets will need to be moved, or possibly, I could follow the
packet-chaining idea and simply chain the arrays together, although that
then makes the coding a bit trickier and becomes one more potential source
of error, but I'm willing to go that route if I'm looking at a severe
penalty that could cause a signficant traffic slowdown when the array is
reallocated.
My second question is in regards to how to handle delays. Suppose I decide a
packet must be delayed, and I want to check in, say 1 second, whether or not
it's time to send the packet. How can I have code that's called on a timer,
(or at least called multiple times per second, if I can't control the
timing), to do this check?
I'll likely have many more questions over the following weeks and months, as
this is my first attempt at doing a device driver.
Thanks.
Pete



Hybrid Mode

