Thread: Get the CPU speed from /proc/cpuinfo

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    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.

  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,218
    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, 05: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, 01:38 PM