public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* System call which gets CPU utilized capacity
@ 2003-09-10  8:27 Alex Vinokur
  2003-09-10 13:30 ` Igor Pechtchanski
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Vinokur @ 2003-09-10  8:27 UTC (permalink / raw)
  To: cygwin

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();
}

--
   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================








--
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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: System call which gets CPU utilized capacity
  2003-09-10  8:27 System call which gets CPU utilized capacity Alex Vinokur
@ 2003-09-10 13:30 ` Igor Pechtchanski
  2003-09-11 15:59   ` Alex Vinokur
  0 siblings, 1 reply; 7+ messages in thread
From: Igor Pechtchanski @ 2003-09-10 13:30 UTC (permalink / raw)
  To: Alex Vinokur; +Cc: cygwin

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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: System call which gets CPU utilized capacity
  2003-09-11 15:59   ` Alex Vinokur
@ 2003-09-11 14:54     ` Cliff Hones
  2003-09-11 15:37       ` Alex Vinokur
  0 siblings, 1 reply; 7+ messages in thread
From: Cliff Hones @ 2003-09-11 14:54 UTC (permalink / raw)
  To: cygwin

Alex Vinokur wrote
> "Igor Pechtchanski" <pechtcha@cs.nyu.edu> wrote in message
news:Pine.GSO.4.56.0309100918590.5235@slinky.cs.nyu.edu...
> > On Wed, 10 Sep 2003, Alex Vinokur wrote:
> >
> > > Is there in CYGWIN any system call which gets CPU utilized capacity at
> > > the present moment?
> >
> [snip]
> > 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
> [snip]
>
> But "top" and "ps" are the UNIX (CYGWIN) command line utilities.
> We can't use them in C-program unless with system().
>  I mean platform-specific system call (as the popen() system call) which
> can be directly used in C-program.

Igor is saying that since 'top' can find the CPU capacity, you just need to
look at the source of top (in procps) to find out how to do it.

-- Cliff


--
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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: System call which gets CPU utilized capacity
  2003-09-11 14:54     ` Cliff Hones
@ 2003-09-11 15:37       ` Alex Vinokur
  2003-09-11 17:24         ` Cliff Hones
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Vinokur @ 2003-09-11 15:37 UTC (permalink / raw)
  To: cygwin


"Cliff Hones" <cliff@aonix.co.uk> wrote in message news:007f01c37833$a42773a0$12760251@ximenes...
> Alex Vinokur wrote
> > "Igor Pechtchanski" <pechtcha@cs.nyu.edu> wrote in message
> news:Pine.GSO.4.56.0309100918590.5235@slinky.cs.nyu.edu...
> > > On Wed, 10 Sep 2003, Alex Vinokur wrote:
> > >
> > > > Is there in CYGWIN any system call which gets CPU utilized capacity at
> > > > the present moment?
> > >
> > [snip]
> > > 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
> > [snip]
> >
> > But "top" and "ps" are the UNIX (CYGWIN) command line utilities.
> > We can't use them in C-program unless with system().
> >  I mean platform-specific system call (as the popen() system call) which
> > can be directly used in C-program.
>
> Igor is saying that since 'top' can find the CPU capacity, you just need to
> look at the source of top (in procps) to find out how to do it.
>
> -- Cliff
>
>

Thanks.

http://www.cygwin.com/packages/procps/procps-010801-1-src
contains _list_ of procps' sources (including top.c and top.h) :
Sun Jan 14 10:40:14 2001          45360 procps-010801/top.c
Sun Jan 14 10:41:29 2001           7242 procps-010801/top.h

Where can one get the sources themselves ?
http://www.cygwin.com/packages/procps/procps-010801/top.c
and
http://www.cygwin.com/packages/procps/procps-010801/top.h
don't exist.

   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================






--
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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: System call which gets CPU utilized capacity
  2003-09-10 13:30 ` Igor Pechtchanski
@ 2003-09-11 15:59   ` Alex Vinokur
  2003-09-11 14:54     ` Cliff Hones
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Vinokur @ 2003-09-11 15:59 UTC (permalink / raw)
  To: cygwin


"Igor Pechtchanski" <pechtcha@cs.nyu.edu> wrote in message news:Pine.GSO.4.56.0309100918590.5235@slinky.cs.nyu.edu...
> On Wed, 10 Sep 2003, Alex Vinokur wrote:
>
> > Is there in CYGWIN any system call which gets CPU utilized capacity at
> > the present moment?
>
[snip]
> 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
[snip]

But "top" and "ps" are the UNIX (CYGWIN) command line utilities.
We can't use them in C-program unless with system().
 I mean platform-specific system call (as the popen() system call) which can be directly used in C-program.

   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================






--
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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: System call which gets CPU utilized capacity
  2003-09-11 15:37       ` Alex Vinokur
@ 2003-09-11 17:24         ` Cliff Hones
  2003-09-15  3:20           ` Alex Vinokur
  0 siblings, 1 reply; 7+ messages in thread
From: Cliff Hones @ 2003-09-11 17:24 UTC (permalink / raw)
  To: cygwin

Alex Vinokur wrote:
> http://www.cygwin.com/packages/procps/procps-010801-1-src
> contains _list_ of procps' sources (including top.c and top.h) :
> Sun Jan 14 10:40:14 2001          45360 procps-010801/top.c
> Sun Jan 14 10:41:29 2001           7242 procps-010801/top.h
> 
> Where can one get the sources themselves ?
> http://www.cygwin.com/packages/procps/procps-010801/top.c
> and
> http://www.cygwin.com/packages/procps/procps-010801/top.h
> don't exist.

You download the source of the package using setup.exe.  Run
setup, and when it gets to the "Select Packages" dialog find
the procps package and tick the little square box under the
"Src" column.

-- Cliff

--
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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: System call which gets CPU utilized capacity
  2003-09-11 17:24         ` Cliff Hones
@ 2003-09-15  3:20           ` Alex Vinokur
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Vinokur @ 2003-09-15  3:20 UTC (permalink / raw)
  To: cygwin


"Cliff Hones" <cliff@aonix.co.uk> wrote in message news:05da01c37889$bb6ecf80$cd8a9dc0@uk.aonix.com...
> Alex Vinokur wrote:
> > http://www.cygwin.com/packages/procps/procps-010801-1-src
> > contains _list_ of procps' sources (including top.c and top.h) :
> > Sun Jan 14 10:40:14 2001          45360 procps-010801/top.c
> > Sun Jan 14 10:41:29 2001           7242 procps-010801/top.h
> >
> > Where can one get the sources themselves ?
> > http://www.cygwin.com/packages/procps/procps-010801/top.c
> > and
> > http://www.cygwin.com/packages/procps/procps-010801/top.h
> > don't exist.
>
> You download the source of the package using setup.exe.  Run
> setup, and when it gets to the "Select Packages" dialog find
> the procps package and tick the little square box under the
> "Src" column.
>
Done.
Thanks.

   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================




--
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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-09-15  3:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-10  8:27 System call which gets CPU utilized capacity Alex Vinokur
2003-09-10 13:30 ` Igor Pechtchanski
2003-09-11 15:59   ` Alex Vinokur
2003-09-11 14:54     ` Cliff Hones
2003-09-11 15:37       ` Alex Vinokur
2003-09-11 17:24         ` Cliff Hones
2003-09-15  3:20           ` Alex Vinokur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).