Get the CPU speed from /proc/cpuinfo

This is a discussion on Get the CPU speed from /proc/cpuinfo within the Linux Programming forums, part of the Platform Specific Boards category; Hi. Can someone guide me to the right direction? I want to make an application that just extracts the cpu ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Location
    Vestfold, Norway
    Posts
    7

    Get the CPU speed from /proc/cpuinfo

    Hi.

    Can someone guide me to the right direction?

    I want to make an application that just extracts the cpu speed, and vendorname from the file /proc/cpuinfo.



    My current distro is Ubuntu 8.10 desktop.

    Regards

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    cat /proc/cpuinfo

    Read the file to see how the information you want is stored.
    Write a program to parse the file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Location
    Vestfold, Norway
    Posts
    7
    Quote Originally Posted by Salem View Post

    Write a program to parse the file.
    This is what I need help doing. I've done all the cat'ing ...

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    1,198
    And what exactly are you having problems with?

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by nerdegutta View Post
    I want to make an application that just extracts the cpu speed, and vendorname from the file /proc/cpuinfo.
    Somebody already did that:

    egrep ("processor|cpu MHz|vendor_id") /proc/cpuinfo

    I threw "processor" in since that is the processor number; if you have more than one this info prints out for each, eg:

    Code:
    processor	: 0
    vendor_id	: GenuineIntel
    cpu MHz		: 2200.074
    processor	: 1
    vendor_id	: GenuineIntel
    cpu MHz		: 2200.074
    Last edited by MK27; 08-01-2009 at 05:33 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Registered User
    Join Date
    Aug 2009
    Location
    Vestfold, Norway
    Posts
    7
    Yes, now we're getting somewhere .

    I've got some ideas.

    Thank you all!

    N

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pthread question
    By quantt in forum Linux Programming
    Replies: 7
    Last Post: 04-07-2009, 01:21 AM
  2. questions on multiple thread programming
    By lehe in forum C Programming
    Replies: 11
    Last Post: 03-27-2009, 07:44 AM
  3. Upgrading my old CPU (for another old one!)
    By foxman in forum Tech Board
    Replies: 16
    Last Post: 01-11-2008, 04:41 PM
  4. getting maximum CPU speed
    By 13th Phazer in forum C++ Programming
    Replies: 14
    Last Post: 10-20-2004, 06:41 PM
  5. How do I discover the CPU Speed?
    By Scripter in forum C Programming
    Replies: 4
    Last Post: 10-27-2002, 12:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21