Solved

CPU usage sys-call

Posted on 2001-07-16
1
332 Views
Last Modified: 2010-04-22
Hi

I want to know the CPU usage from a program in C. Is there a sys-call ???

Thanks,

Liron
0
Comment
Question by:lirong
1 Comment
 

Accepted Solution

by:
PaulSmirnoff earned 50 total points
ID: 6285907
no syscalls, just access to /dev/kmem

man kvm_read

try to look how it is done in vmstat.c

name is '_cp_time'

--- cut
void
kread(nlx, addr, size)
        int nlx;
        void *addr;
        size_t size;
{
        char *sym;  
           
        if (namelist[nlx].n_type == 0 || namelist[nlx].n_value == 0) {
                sym = namelist[nlx].n_name;
                if (*sym == '_')
                        ++sym;
                errx(1, "symbol %s not defined", sym);
        }
        if (kvm_read(kd, namelist[nlx].n_value, addr, size) != size) {
                sym = namelist[nlx].n_name;
                if (*sym == '_')
                        ++sym;
                errx(1, "%s: %s", sym, kvm_geterr(kd));
        }
}
--- cut

Paul
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question