Re: Queues, prioritization, changing priorities and algorithms
From: Brad BARCLAY (bbarclay_at_jsyncmanager.org)
Date: 10/06/03
- Next message: Rob Ratcliff: "Re: Help Me!"
- Previous message: viator: "Re: Help Me!"
- In reply to: AlanR: "Queues, prioritization, changing priorities and algorithms"
- Next in thread: AlanR: "Re: Queues, prioritization, changing priorities and algorithms"
- Reply: AlanR: "Re: Queues, prioritization, changing priorities and algorithms"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 06 Oct 2003 00:11:22 GMT
AlanR wrote:
> I have looked at using multiple LinkedLists, one for each priority,
> but the cost of adding and removing items every time a priority
> changes would be too high. ie. the suppliers to the queue are
> multithreaded. The synchronization/locking would be too costly if the
> queues also need to be locked every time an item's priority changes.
> So I'm thinking of using a single linked list. This means there is no
> need to synchronize the list when a priority changes. However, this
> means that the consumer of the queue must iterate across the queue
> every time it consumes. If the high priority items happen to be near
> the back of the queue, this could get costly.
>
> Has anyone any experience, advice or info on this.
Yes, you need a data structure called a "priority queue". These have
been around for decades -- you should find all sorts of hits if you do a
web search on this topic.
Basically, what you want to do is to enqueue items based on their
priority, as opposed to just sticking them at the back. In this way,
you don't have to scan the queue each time you need to consume an item
-- just take the item at the front.
Brad BARCLAY
-- =-=-=-=-=-=-=-=-= From the OS/2 WARP v4.5 Desktop of Brad BARCLAY. The jSyncManager Project: http://www.jsyncmanager.org
- Next message: Rob Ratcliff: "Re: Help Me!"
- Previous message: viator: "Re: Help Me!"
- In reply to: AlanR: "Queues, prioritization, changing priorities and algorithms"
- Next in thread: AlanR: "Re: Queues, prioritization, changing priorities and algorithms"
- Reply: AlanR: "Re: Queues, prioritization, changing priorities and algorithms"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|