Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #19963

Re: Question of throttling CPU usage

From Fred K <fred.l.kleinschmidt@gmail.com>
Newsgroups comp.lang.c
Subject Re: Question of throttling CPU usage
Date 2012-04-26 07:44 -0700
Organization http://groups.google.com
Message-ID <30980468.232.1335451461360.JavaMail.geo-discussion-forums@pbcrp8> (permalink)
References (3 earlier) <4F9857B3.3080402@verizon.net> <4543ab86-aafd-4500-94f3-0fd954c2de51@f5g2000vbt.googlegroups.com> <9vrclmFi68U11@mid.individual.net> <0c88c621-fe73-4530-beda-50b52b0c504f@l3g2000vbv.googlegroups.com> <pan.2012.04.26.13.33.31.515000@nowhere.com>

Show all headers | View raw


On Thursday, April 26, 2012 6:33:32 AM UTC-7, Nobody wrote:
> On Thu, 26 Apr 2012 01:41:06 -0700, jon.harding wrote:
> 
> > OK, and I am sorry to labour the point here, but how can I do this
> > outside the application then?
> > 
> > Here are the requirements:
> > 1. My program will run hopefully on Windows and Linux.
> > 2. My program should run at a set CPU percentage and not exceed it.
> > 3. The CPU percentage may be different depending on the time of day;
> > ie after 6pm and over a lunch break 12:30 - 1:00pm it will run at 85%
> > utilization, but at other times around 10%
> 
> You'll probably have to do it within the application, using
> platform-specific functionality (e.g. sleep, usleep or nanosleep on Unix,
> Sleep on Windows).
> 
> Very few real programs can be written using only the functionality
> provided by the library. E.g. almost all file handling is
> platform-specific: even with <stdio.h>, the standard doesn't specify which
> filenames are valid, and the standard makes no mention of directories.

Regardless of what you use to try slowing the program down, you probably can't cause it to use a specific amount of the CPU time. There are likely to be many other things running at the same time that you have no control over, and they will share CPU time with your progam. 

Suppose you specify your program to use 85% of the CPU time. Now run two instances of your program at the same time. Do you really expect each of them to use 85% of the CPU time?

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Question of throttling CPU usage jon.harding@gmx.co.uk - 2012-04-25 11:22 -0700
  Re: Question of throttling CPU usage James Kuyper <jameskuyper@verizon.net> - 2012-04-25 14:44 -0400
    Re: Question of throttling CPU usage jon.harding@gmx.co.uk - 2012-04-25 12:35 -0700
      Re: Question of throttling CPU usage Thomas Richter <thor@math.tu-berlin.de> - 2012-04-25 21:39 +0200
      Re: Question of throttling CPU usage James Kuyper <jameskuyper@verizon.net> - 2012-04-25 15:59 -0400
        Re: Question of throttling CPU usage jon.harding@gmx.co.uk - 2012-04-25 15:33 -0700
          Re: Question of throttling CPU usage Ian Collins <ian-news@hotmail.com> - 2012-04-26 10:37 +1200
            Re: Question of throttling CPU usage jon.harding@gmx.co.uk - 2012-04-26 01:41 -0700
              Re: Question of throttling CPU usage Robert Wessel <robertwessel2@yahoo.com> - 2012-04-26 04:25 -0500
              Re: Question of throttling CPU usage James Kuyper <jameskuyper@verizon.net> - 2012-04-26 06:59 -0400
                Re: Question of throttling CPU usage Robert Miles <milesrf@Usenet-News.net> - 2012-05-27 23:35 -0500
              Re: Question of throttling CPU usage Nobody <nobody@nowhere.com> - 2012-04-26 14:33 +0100
                Re: Question of throttling CPU usage Fred K <fred.l.kleinschmidt@gmail.com> - 2012-04-26 07:44 -0700
                Re: Question of throttling CPU usage James Kuyper <jameskuyper@verizon.net> - 2012-04-26 11:45 -0400
        Re: Question of throttling CPU usage Nobody <nobody@nowhere.com> - 2012-04-26 14:27 +0100
      Re: Question of throttling CPU usage tom st denis <tom@iahu.ca> - 2012-04-26 12:01 -0700
      Re: Question of throttling CPU usage Robert Miles <milesrf@Usenet-News.net> - 2012-05-27 23:19 -0500
    Re: Question of throttling CPU usage Lanarcam <lanarcam1@yahoo.fr> - 2012-04-25 21:39 +0200

csiph-web