Re: small footprint priortiy queue
- From: Anton Erasmus <nobody@xxxxxxxxxxxxxxxx>
- Date: Sat, 11 Feb 2006 13:15:00 +0200
On 11 Feb 2006 03:01:20 -0800, "Gerr" <gertvierman@xxxxxxxxxxx> wrote:
Oops, I forgot to set a proper follow-up on my original post, my
apologies.
Paul Keinanen wrote:
On 11 Feb 2006 00:46:13 -0800, "Gerr" <gertvierman@xxxxxxxxxxx> wrote:
This would be no problem when the queue was implemented as some kind of
dynamic data structure (linked list, etc), but as I said before, this
is no option because of memory restrictions.
Linked lists do not require a dynamic memory allocation system.
True.
Simply put all free memory into a pool of equal size blocks and put
them all initially into the 'Free' list. If the memory block are of
the same size, there is no point of storing a full pointer to the next
block, but just use an index into the next block. With 16 entries, try
to find 4 free bits from each entry for the pointer value. Thus, you
will be able to walk the priority queue.
This is an alternative I already considered. But before re-inventing
the wheel (I happen to do that every now and then), I wanted to hear
some other opinions about possible solutions.
Do you really need a priority queue ?
Maybe I don't.
What I need is a way to make sure some events are handled with a higher
priority then others (in this case, received network messages are
considered 'more important' then keyboard presses). Since the system
already uses a single queue, the obvious solution of was to rework the
queue mechanism to allow high-prio events to be inserted before others,
instead of putting them on the end of the queue. This would probably
have the least impact on the rest of the project, since all the changes
occur inside the event-queue handling code only. Only the queue itself
needs to know the priority for each kind of event, the rest of the
modules can be oblivious of this.
If you have only a few priority levels, then you can have different
queues for different priority levels. Tasks from higher a priority
queue gets executed before tasks from a lower priority queue.
If your current code is written in a resonable manner, you can use
the same code to handle the different queues.
Regards
Anton Erasmus
.
- Prev by Date: Re: Starting
- Next by Date: Re: small footprint priortiy queue
- Previous by thread: How do I hash this?
- Next by thread: Re: small footprint priortiy queue
- Index(es):
Relevant Pages
|