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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:22:52+00:00 2026-05-28T02:22:52+00:00

I have a dual core processor and according to the explanation I’m able to

  • 0

I have a dual core processor and according to the explanation I’m able to use only 2 threads but actually I’m able to launch more than 2 threads at same time:

Here is a copy of the explanation:

The static hardware_concurrency() method, provided by the
boost::thread class, returns the number of threads that could
physically be executed at the same time based on the underlying number
of CPUs or CPU cores. Calling this function on a commonly used
dual-core machine, a value of 2 is returned. This allows for a simple
method to identify the theoretical maximum number of threads that
should be used simultaneously by a given multithreaded application.

hardware_concurrency() method returns number 2 in my case, but this program uses 4 threads at same time:

#include <iostream>
#include <boost\thread.hpp>

using namespace std;
using boost::thread;
using namespace boost::this_thread;
using boost::posix_time::seconds;

void f1()
{
    for(int i = 0; i < 10; ++i)
    {
        cout << i << endl;
        sleep(seconds(2));
    }
}

void f2()
{
    for(int i = 0; i < 10; ++i)
    {
        cout << i << endl;
        sleep(seconds(2));
    }
}

int main()
{
    // 4 threads are executed on dual core machine (no problem)
    thread thr1(f1);
    thread thr2(f2);
    thread thr3(f1);
    thread thr4(f2);
    cin.ignore();
    return 0;
}

Can anyone explain that behavior?

  • 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-28T02:22:53+00:00Added an answer on May 28, 2026 at 2:22 am

    The term threads usually covers three abstraction layers:

    1. User threads are threads launched by applications and are mapped N:M to:
    2. Kernel threads, which are threads managed by the operating system, mapped N:M to:
    3. Hardware threads, which are the actual physical resources available.

    The 4 threads you said are launched by the application are from category 1 (user threads), while the value 2 returned by that function refers to category 3 (hardware threads). Since the mapping is N:M across the layers, you can see that you can have several user threads mapped to a smaller number of hardware threads.

    Having said this, typically starting more than 2x the number of hardware threads if you are doing intensive computations will hurt performance due to context switches and resource contention.

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

Sidebar

Related Questions

I have to build a dual-core processor simulator in C (it's actually a multilevel
I have some XML tagged string as follows. <Processor>AMD Athlon(tm) 64 X2 Dual Core
I have an AMD Athlon II P320 Dual-Core Processor 2.10 GHz. I'm trying to
I have a dual socket 8 core processor, that is, each processor has 4-cores
Platform: Windows XP Processor : Dual Core I have a program written in C
Even though I have a robust and fast computer (Pentium Dual Core 2.0 with
I have been doing some test on my Pentium D (an old dual core
Currently we have developed application using Java 6 based on windows 32bit(Dual core &
My openMP version did not give any speed boost. I have a dual core
I have read that in a multi core processor each core contains 2 hardware

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.