Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sorted atomic linked list algorithm (priority queue)

Tags:

c++

c

algorithm

Can somebody point me towards an algorithm for a sorted thread-safe atomic (lock-free) linked list/priority queue? I'm aware of how to do just a linked list itself, but now I need one that is sorted. I'm unsure if this is minor change or significant redesign compared to an unsorted list, thus would like to see an existing algorithm before I make my own.

It needn't actually be a list (or technically sorted), but behaves like a priority queue with these properties:

  • lowest element is the one with the minimum integer field value
  • access to lowest element in constant time
  • modification via atomic operations only (no locks)
  • insertion/removal in linear time

The contents will likely be pointers to structures. The integer field to sort is one of the members of that structure.

This is for a C++ program, but I don't need code examples, an algorithm description is fine. Algorithms which come close, but not perfect, are also appreciated.

like image 468
edA-qa mort-ora-y Avatar asked Mar 26 '11 06:03

edA-qa mort-ora-y


People also ask

Is priority queue sorted?

This priority queue will be sorted according to the same comparator as the given collection, or according to its elements' natural order if the collection is sorted according to its elements' natural order. Parameters: c - the collection whose elements are to be placed into this priority queue.

What is priority queue explain with example?

A priority queue is a special type of queue in which each element is associated with a priority value. And, elements are served on the basis of their priority. That is, higher priority elements are served first. However, if elements with the same priority occur, they are served according to their order in the queue.

How is priority queue implemented?

Priority Queues can be implemented using common data structures like arrays, linked-lists, heaps and binary trees. The list is so created so that the highest priority element is always at the head of the list. The list is arranged in descending order of elements based on their priority.

How is priority decided in priority queue?

In Priority queue items are ordered by key value so that item with the lowest value of key is at front and item with the highest value of key is at rear or vice versa. So we're assigned priority to item based on its key value. Lower the value, higher the priority.


1 Answers

Look at this: "Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems". Googling will give you more links for sure.

like image 91
Alexey Kukanov Avatar answered Oct 23 '22 18:10

Alexey Kukanov