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 7960305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:43:05+00:00 2026-06-04T04:43:05+00:00

I am using a canonical ring buffer implementation in a 1Reader thread/1Writer thread setting.

  • 0

I am using a canonical ring buffer implementation in a 1Reader thread/1Writer thread setting.

Since the reader loops when the buffer is empty [the writer loops when the buffer is full] and continously polls the control variables, I call pthread_yield (that in my case is only a wrapper to sched_yield) to give priority to other threads in the system. I am not using any mutex because it is not needed for proper functioning.

Is there a better way to mitigate the polling effects (a.k.a. CPU burning) ? I was thinking of the pthread’s condition variables – since I mostly block the thread when there is no data [no space] – but I am afraid of the overhead could introduce.

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-04T04:43:06+00:00Added an answer on June 4, 2026 at 4:43 am

    Use condition variables, the overhead is much lower than busy waiting, and using mutexes correctly ensures that your data is actually there when you expect it to be (since they enforce ordering).

    In addition, if you really don’t need the mutex for the general case, lock contention should be low to non-existent.

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

Sidebar

Related Questions

I am trying to compile the canonical metamodel classes for some JPA entities using
The canonical implementation of length :: [a] -> Int is: length [] = 0
Does a canonical user id exist for a federated user created using STS? When
I'm trying to get started using Python for KDE development. What is the canonical
The canonical JVM implementation from Sun applies some pretty sophisticated optimization to bytecode to
Is there a canonical way of doing that? I've been using head -n |
I'm using ModRewrite to redirect URLs to their canonical ones in my .htaccess file.
I always think of having to use pointers for polymorphism. Using the canonical example:
I am using mysqldump to create a canonical installation script for a MySQL database.
I'm using the following mod rewrites to ensure not only canonical URLs, but also

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.