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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:11:40+00:00 2026-05-26T06:11:40+00:00

I am learning the concept of threads in c/c++. I was trying the examples

  • 0

I am learning the concept of threads in c/c++. I was trying the examples for
the dot product of two vectors cited in Pthreads Overview.

  • Serial version

  • Pthreads version

I ran both the serial and the thread version of the code and I found that the
serial version was faster than the thread version. I thought it should be the
opposite.

I am running on a single CPU.

  • 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-26T06:11:40+00:00Added an answer on May 26, 2026 at 6:11 am

    The code that link to has a few issues that you need to keep in mind:

    1. The serial version is doing an inner product of two length-100 vectors. The parallel version is doing an inner product of two length-400 vectors. You can see that in the array allocation (e.g., a = (double*) malloc (NUMTHRDS*VECLEN*sizeof(double)); — NUMTHRDS is set to four and VECLEN 100 in the code). Therefore, the parallel program is doing four times the amount of work, but with four threads, so the naive assumption is that the serial and parallel programs will have the same run time.
    2. The parallel code is demonstrating a mutex for thread synchronization. This may be creating barriers in the code as it runs.
    3. The code is using four threads. If your CPU does not have four or more threads, then you cannot expect it to scale.
    4. There is an overhead in creating the threads, and with such a small problem it is probably a significant factor.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started learning NServiceBus and trying to understand the concept. When it talks about
I'm learning Silverlight and am trying to ingest some new concepts. Just so I
I am just starting Ruby and learning the concept of modules. I understand that
Is there a machine learning concept (algorithm or multi-classifier system) that can detect the
I am learning the concept of sequence and nil in Clojure. This was the
I'm self-learning the REST concept and am playing with the Flickr API. One of
I am learning Lua and have come across the concept of anonymous functions. It's
I'm learning iOS and I'm working on what amounts to a Proof of Concept
As I'm currently learning Django / Python, I've not really been using the concept
I'm learning iPhone/iPad programming. I believe I understand the concept of MVC; what I'm

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.