wu :: forums
« wu :: forums - shared memory queues »

Welcome, Guest. Please Login or Register.
Jan 5th, 2025, 1:04am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: william wu, ThudnBlunder, Grimbal, Eigenray, towr, SMQ, Icarus)
   shared memory queues
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: shared memory queues  (Read 516 times)
cuckoo
Junior Member
**





   


Gender: male
Posts: 57
shared memory queues  
« on: Jul 24th, 2007, 10:43pm »
Quote Quote Modify Modify

Give a good data structure for having n queues (n not fixed) in a finite memory segment. You can have some data-structure separate for each queue. Try to use at least 90% of the memory space.  
 
Any good ideas?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: shared memory queues  
« Reply #1 on: Jul 25th, 2007, 12:44am »
Quote Quote Modify Modify

You could use an list/tree/heap of linked lists.
Of course that'd waste a lot of space on pointers if the elements you store are small.
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
sk
Newbie
*





   


Posts: 45
Re: shared memory queues  
« Reply #2 on: Sep 3rd, 2007, 7:45pm »
Quote Quote Modify Modify

u can use a circular queue with n heads and tails.
 
queue full condition is checked if the tail hits the next head.
tail[i] hits head[i+1%n];
whenever a new queue has to be created, the space between the last tail and the first head can be divided into 2 segments and the new queue head can be assigned to lasttail + (lasttail - firsthead)/2 % n.
 
Maybe some math can be adjusted here to determine which is the best alocation.
-----
 
other alternative
as towr suggested list of queues, or trees
« Last Edit: Sep 3rd, 2007, 7:45pm by sk » IP Logged
gotit
Uberpuzzler
*****





   
Email

Gender: male
Posts: 804
Re: shared memory queues  
« Reply #3 on: Sep 4th, 2007, 1:34am »
Quote Quote Modify Modify

I don't quiet get the reason behind using a list/tree/heap of linked list, as towr has said. Are we using the list/tree/heap to assign some kind of priority to the queues?
IP Logged

All signatures are false.
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: shared memory queues  
« Reply #4 on: Sep 4th, 2007, 4:44am »
Quote Quote Modify Modify

on Sep 4th, 2007, 1:34am, gotit wrote:
I don't quiet get the reason behind using a list/tree/heap of linked list, as towr has said. Are we using the list/tree/heap to assign some kind of priority to the queues?
Or some kind of sorting.
It really depends on why we want n different queues in the first place.  
 
In any case we need a datastructure to tie the n queues together in some way, and since n is not fixed, we need a variable datastructure to do this. Lists, trees and heaps then come to mind.
 
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board