LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2009, 08:54 AM   #1
naveenisback
Member
 
Registered: Jun 2009
Posts: 80
Blog Entries: 1

Rep: Reputation: 16
getting cpu info, system info thru system calls


Hi

OS : ubuntu
language:C/C++


I want to get the whole contents of cpu info, throttling, battery status like information. through system calls only and have to store them in a structure.. pls dont suggest:1) reading /proc/cpuinfo 2)script program 3) system command

I want only system calls except uname();

in windows we have APIS to get all those above mentioned infos. So is there any system calls like that. pls guide me
 
Old 09-29-2009, 09:14 AM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by naveenisback View Post
pls dont suggest:1) reading /proc/cpuinfo
Why not.

What is wrong with reading system info from /proc ?

Quote:
Originally Posted by naveenisback View Post
in windows we have APIS to get all those above mentioned infos.
The Windows way is not necessarily (nor even very often) the right way.

Part of the Unix design philosophy is to have fewer OS API's than you would find in a non Unix OS and to use the basic file I/O APIs in imaginative ways to reduce the need for other APIs.

The /proc filesystem is a logical extension of that philosophy. I think Linux has or had various APIs to get some of the same info that you can get from /proc, but using /proc is more general and more likely to be able to smoothly transition as the underlying OS features are changed or enhanced.

Last edited by johnsfine; 09-29-2009 at 09:20 AM.
 
Old 09-30-2009, 01:04 AM   #3
naveenisback
Member
 
Registered: Jun 2009
Posts: 80

Original Poster
Blog Entries: 1

Rep: Reputation: 16
ya ofcourse.. I agree with u.. If we read /proc/cpuinfo, the problem is with parsing the file to get the our needed appropriate information and storing them back in a structure variables. It increases my program size. So asked. If u know the APIs please post it.
 
Old 09-30-2009, 01:27 AM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
write it,
it wont take more then 5K if you do it right
hint: fscanf() and sscanf can be one of your best friend for parsing that and fgets
 
Old 06-11-2010, 05:38 AM   #5
maurya.ravi
LQ Newbie
 
Registered: Jun 2010
Posts: 2

Rep: Reputation: 0
Is any system call to read info like /proc/cpuinfo

Is any system call to read info like /proc/cpuinfo.

Actullay i can read it through /proc/cpuinfo but the details are different at intell & PPC. So there is some portability problem of the program.

thanx
 
Old 06-11-2010, 05:54 AM   #6
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by maurya.ravi View Post
I want to get the whole contents of cpu info, throttling, battery status like information. through system calls only
See the following pdf:
http://www.digilife.be/quickreferenc...0Reference.pdf

Last edited by Aquarius_Girl; 06-11-2010 at 06:12 AM. Reason: user name changed
 
Old 06-11-2010, 08:19 AM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by anishakaul View Post
Thanks. I don't have time for a careful enough read to see if that has any answers to the OP's question. But slightly off topic:

Do you know of a similar document for X86_64 architecture Linux system calls?
 
Old 06-11-2010, 02:06 PM   #8
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

1. Reading from "/proc/info" is in fact, for most purposes, the ideal approach for Linux

2. Granted - "/proc/info" is not necessarily portable to other *nix systems. And certainly not portable to Windows.

The Windows equivalent is WMI ... which is 100x more verbose ... and not portable to anything outside of Windows.

3. Of course the information in "/proc/info" is different between x86 and PPC - they're different architectures!

4. The claim that parsing /proc/info would somehow make the program "bigger" in some significant way ... is just absurd.

IMHO .. PM
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find out if my system is i386, i486, or i586? Is there a system info command? mlsbraves Linux - General 6 02-17-2009 04:08 PM
How to get info from system calls in Linux using C++ tnjones Programming 2 10-19-2008 10:53 AM
System info peterkcse Linux - General 2 10-26-2004 06:09 PM
system info meeh Linux - Hardware 2 01-17-2003 04:22 AM
System Info / System Audit munyard Linux - Software 1 01-08-2003 01:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration