LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-29-2004, 07:17 PM   #1
rigasminho
LQ Newbie
 
Registered: Feb 2004
Posts: 3

Rep: Reputation: 0
Question Line Kernal - Processor Type


Does anyone know how to do this?
Write a program to report the behavior of the Linux kernel. Your program should have three different options. The default version should print the following values

on the stdout:
•Processor type
•Kernel version
•Amount of time since the system was last booted
 
Old 02-29-2004, 07:18 PM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
what language ?!
/proc/cpuinfo
uname -r
uptime
 
Old 02-29-2004, 07:25 PM   #3
rigasminho
LQ Newbie
 
Registered: Feb 2004
Posts: 3

Original Poster
Rep: Reputation: 0
i need to make a program that does those three things. not the command lines. it has to be in C as well. thanks.
 
Old 02-29-2004, 08:02 PM   #4
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
well d00d to me this sounds like your homework ...
just how you asked the question ... thats the feeling i get ...
so before we start getting into the code, why don't you show us what you have done so far and where you are getting hung up at ... i think that'll be the best place to start ...
 
Old 02-29-2004, 08:17 PM   #5
rigasminho
LQ Newbie
 
Registered: Feb 2004
Posts: 3

Original Poster
Rep: Reputation: 0
wow d00d you must be super smart to figure that one out. it is my hw, but i figured some of it. heres what i ahve so far.

#include <stdio.h>
#include <sys/utsname.h>

int main ()
{
struct utsname u;
uname (&u);
printf ("%s release %s (version %s) on %s\n", u.sysname, u.release,
u.version, u.machine);
return 0;
}

and i have this,
#include <linux/kernel.h>
#include <linux/sys.h>
#include <stdio.h>
#include <sys/sysinfo.h>

int main ()
{
/* Conversion constants. */
const long minute = 60;
const long hour = minute * 60;
const long day = hour * 24;
const double megabyte = 1024 * 1024;
/* Obtain system statistics. */
struct sysinfo si;
sysinfo (&si);
/* Summarize interesting values. */
printf ("system uptime : %ld days, %ld:%02ld:%02ld\n",
si.uptime / day, (si.uptime % day) / hour,
(si.uptime % hour) / minute, si.uptime % minute);
printf ("total RAM : %5.1f MB\n", si.totalram / megabyte);
printf ("free RAM : %5.1f MB\n", si.freeram / megabyte);
printf ("process count : %d\n", si.procs);
return 0;
}


so i did some work. wanna help me figure out the rest of it?
A second version of the program should print the same information as the first
version plus:
•The amount of time processor has spent in user mode, system mode, ad the
amount amount of time the system was idle
•The number of disk read / write request made on the system
•The number of context switches the kernel has performed
•The time at which the system was last booted
•The number of processes that have been created since the system was booted.
 
Old 02-29-2004, 08:29 PM   #6
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
man times for the processor times, and man proc for all that other stuff.
 
Old 03-02-2004, 08:09 AM   #7
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 276

Rep: Reputation: 31
Get the source code of uptime, that'll help with most of the stuff. It's
probably in binutils or shellutils. To get information about the cpu, you
may use x86 instruction cpuinf.


HTH
 
  


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
I need to kow about my type of processor can someone help me repollo Linux - Newbie 2 08-27-2005 09:45 PM
Processor Type spaaarky21 Linux - Hardware 1 02-08-2005 01:36 AM
how to find processor type on linux on zos ? gonwg Linux - Newbie 3 09-11-2004 04:47 PM
processor type Abe_the_Man Linux - Newbie 1 08-24-2003 11:42 PM
preferred processor type frieza Linux - General 13 04-07-2002 11:14 AM

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

All times are GMT -5. The time now is 09:08 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