Thread: finding number of cores in a multi-core processor

  1. #1
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459

    finding number of cores in a multi-core processor

    Is there a way to find the number of cores in a multi-core system using a command-line, or library function? I want to do this because I want to re-write my programs to be multithreaded and take advantage of multiple cores. Specifically I'm coding in Java, but anything would help. Thanks.

    -da
    hasafraggin shizigishin oppashigger...

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    C++0x will provide std::thread::get_hardware_concurrency(). That probably doesn't help you, though.

    Not a C++ question, moving to Tech.


    Try java.lang.Runtime.availableProcessors().
    Last edited by CornedBee; 03-04-2008 at 03:14 AM.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    In windows use GetSystemInfo()

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Related thread: Maximum concurrency

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding largest number in array
    By el_chupacabra in forum C Programming
    Replies: 2
    Last Post: 01-22-2009, 02:31 PM
  2. Number Guessing
    By blacknapalm in forum C Programming
    Replies: 2
    Last Post: 10-01-2008, 01:48 AM
  3. Replies: 8
    Last Post: 09-27-2008, 07:32 PM
  4. finding the largest number in a binary search
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 07-31-2008, 03:19 AM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM