Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:12:52+00:00 2026-06-13T07:12:52+00:00

I recently took a stab at implementing a concurrent priority queue using a skip-list

  • 0

I recently took a stab at implementing a concurrent priority queue using a skip-list data structure – for the sake of this question, if you don’t know what a skip-list is, I believe just picturing a linked list would be sufficient enough to answer. I attempted minimal locking (i.e. allowing multiple enqueues and dequeues simultaneously, only locking nodes or their forward pointers if necessary, releasing locks as soon as possible, traversing the list using Interlocked’s, etc).

I was pleased with the results. However, writing a regular skiplist with the add and remove surrounded by a syncroot lock (i.e. only allowing one operation at any given time), was actually twice as fast.

I assumed that I must have bug in my implementation. However, even a ‘Concurrent Priority Queue’ listed on the Microsoft website, only actually allows for one operation at a time (i.e. a syncroot lock around enqueue and dequeue)

http://code.msdn.microsoft.com/Samples-for-Parallel-b4b76364/sourcecode?fileId=44488&pathId=1696822056

As a general rule, (and forgive me if this question is too general), at what point does more granular locking actually lead to a performance improvement? I imagine that in my case, since I actually have to traverse large lists with Interlocked.Exchange (is there a better way?) as well as multiple test and test and set’s, etc, that this slows down the enqueues and dequeues.

Additionally, is there a tool that could help me determine where the majority of the time is being spent? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:12:53+00:00Added an answer on June 13, 2026 at 7:12 am

    There is an overhead of constantly checking if a locked region is currently free, setting the lock, and then releasing it when leaving. If, in practice, you very rarely actually compete with anyone else for access to that critical section you have just performed that overhead for no beneficial reason. If, on the other hand, there are lots and lots of threads trying to use your data structure then you may find that the increased performance from running actions in parallel (if you have a many cored CPU) exceeds the overhead of managing the locks.

    With these types of data structures it’s a rather uncommon case to have several dozen threads all trying to use the data structure at the same time, while performing operations that wouldn’t usually require them to wait for each other. So, in short, you could probably generate test cases that resulted in your lesser lock cases performing better by adding threads, and properly managing what they are all doing. If your current tests are a reasonable representation of how you actually plan to use the data structure then clearly your uses won’t benefit from a more elaborate locking scheme.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently took part in ACM certified programming competition. This is the question which
Recently I had this question , and everything worked properly until I sent it
Recently, i took ownership of some c++ code. I am going to maintain this
I have a question about a code that I have recently took in my
I recently took over a project that has a pretty dirty database... The table
I recently took over management of a Windows 2003 server. The application log is
So, I recently took a job where I need to develop a fairly simple
Recently I encountered a bug in an application I took over from another developer.
I've recently come across a C program in which the main function only took
Recently, i am working with jquery for my mini-project. I took a code from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.