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

  • Home
  • SEARCH
  • 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 6664237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:35:18+00:00 2026-05-26T02:35:18+00:00

Which is generally more efficient between locking a mutex and doing disk reads in

  • 0

Which is generally more efficient between locking a mutex and doing disk reads in C++?

If it depends on the system I’m running, what’s a good way to check this? Would doing 1 million locks vs 1 million disk reads work?

  • 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-05-26T02:35:18+00:00Added an answer on May 26, 2026 at 2:35 am

    Generally, the mutex operations would be far faster than disk reads. That’s because their intended purpose requires maximum speed. In fact, I would hazard to suggest that any memory operation is likely to be faster than a disk one.

    Of course, there may be bizarre edge cases where the disk information is cached in memory and
    you read the same byte over and over but that’s not really doing a disk read, is it?

    If you find yourself with a desire to check this (and I would suggest it’s not really necessary), simply code up a couple of programs, the first which locks and unlocks a mutex a million times, the second which reads a million different pieces of information off the disk.

    Run them and compare them. If, by some bizarre factor, the disk reads come back faster, show us your code and we’ll explain what you did wrong 🙂

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

Sidebar

Related Questions

Does anyone know in which programming language the Googlebot was written? Or, more generally,
Which of these is more efficient in terms of speed (number of lines of
In MySQL, is it generally faster/more efficient/scalable to return 100 rows with 3 columns,
For general protocol message exchange, which can tolerate some packet loss. How much more
I am currently working on some simple custom allocators in c++ which generally works
Which is generally fastest when reading/comparing row info from a DataTable? 'assume dt as
The default shell in Mac OS X is bash , which I'm generally happy
General javascript question here, which would also be good to know how(if possible) to
Can somebody please demonstrate for me a more efficient Cartesian product algorithm than the
Back in the good old days of 68k, both pre/post pointer increments/decrements were more

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.