From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13821 invoked by alias); 10 Sep 2003 13:30:17 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 13805 invoked from network); 10 Sep 2003 13:30:16 -0000 Received: from unknown (HELO slinky.cs.nyu.edu) (128.122.20.14) by sources.redhat.com with SMTP; 10 Sep 2003 13:30:16 -0000 Received: from slinky.cs.nyu.edu (localhost [127.0.0.1]) by slinky.cs.nyu.edu (8.12.9+Sun/8.12.9) with ESMTP id h8ADMlmL026280; Wed, 10 Sep 2003 09:22:47 -0400 (EDT) Received: from localhost (pechtcha@localhost) by slinky.cs.nyu.edu (8.12.9+Sun/8.12.2/Submit) with ESMTP id h8ADMkMl026277; Wed, 10 Sep 2003 09:22:47 -0400 (EDT) X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Wed, 10 Sep 2003 13:30:00 -0000 From: Igor Pechtchanski Reply-To: cygwin@cygwin.com To: Alex Vinokur cc: cygwin@cygwin.com Subject: Re: System call which gets CPU utilized capacity In-Reply-To: Message-ID: References: Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-09/txt/msg00619.txt.bz2 On Wed, 10 Sep 2003, Alex Vinokur wrote: > Is there in CYGWIN any system call which gets CPU utilized capacity at > the present moment? > For instance : > int get_cpu_usage() which returns the percentage of used capacity. > > I would like to write in my C-program something like : > > if (get_cpu_usage() < 20) > { > foo1(); // calling foo1() will be postponed > } > else > { > foo2(); > } I assume the call is the same as in any other Unix system, since "top" worked for me with almost no porting about a year ago. You might want to take a look at the sources for the "procps" package. Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha@cs.nyu.edu ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/