🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4302

Re: CPU load - How can I measure it?

#4302
From: Alberto
Date: Wed, 08 Feb 2006 17:40
42 lines
3379 bytes
Bob Gonder wrote:
> Alberto wrote:
> 
>>> What you are asking doesn't really make sense.
>>> If there is nothing else running, then you will get 100% of the CPU.
>>> OTOH if your programm is running twice, you will get 50%.
>> It makes a perfect sense. The program is driven by external interrupts.
> 
> Ok, so now all of a sudden, we're working under interrupts.
> What kind of interrupts are they? Are they hardware interrupts, or do
> you have a program running, looking at a port, that then calls the
> filter?
> DOS style hardware interrupts can do their job before releasing their
> lock on the cpu. That job should be as short as possible.

The interrupts are those generated by a sound card, and being taken care of
by the sound card driver. After each interrupt, the Windows MME system posts
an event control block which one of my threads is waiting upon.
The thread is so awakened, does what it has to do, and goes back to wait for
the next event. It runs at a priority higher than normal, to minimize
the risk of not being scheduled when needed, as this would generate chopped
audio. The filtering is done in real time. The risk of being scheduled
a bit too later than when needed increases with increasing CPU load, despite
the higher thread priority. so I have to monitor the load to reduce the
amount of processing done by my thread to avoid chopped audio.
An imperfect filtering is by far better than an audio with interruptions.
All of this is not theory, it works, I have done tests where I communicated
an artificial load to the thread via the keyboard, managed by another
asynchronous thread.

What I need is to automate the process, dynamically measuring the actual
CPU load, and sending this value to the working thread, instead of simulating
it with the keyboard.

 From what I have seen up to now, the API GetSystemTimes() would allow me
to do that. The only problem with this solution is that it works only
with Win2k and WinXP, but not with Win98SE. As many of my users are still
using Win98SE, I am in search of a solution compatible with this latter OS.

Thanks

Alberto di Bene
Technical Details
Message-ID: <43ea2c47$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news2.volia.net!border1.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43e53514@newsgroups.borland.com> <40bcu1hlup9hqfr2qfnl6ob26jaudlqvmt@4ax.com> <43e68b34$1@newsgroups.borland.com> <bqadu11e4stdsh8bhpqblqalm6t7queu8t@4ax.com> <43e91b0d$1@newsgroups.borland.com> <e54ku1le1ionfmrg5a3n647r7jkb55auq5@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e1eea742f875d72d
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 08 Feb 2006 18:40:54 +0100
From: Alberto <dibene@usa.net>
User-Agent: Thunderbird 1.5 (Windows/20051201)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: CPU load - How can I measure it?
References: <43e53514@newsgroups.borland.com> <40bcu1hlup9hqfr2qfnl6ob26jaudlqvmt@4ax.com> <43e68b34$1@newsgroups.borland.com> <bqadu11e4stdsh8bhpqblqalm6t7queu8t@4ax.com> <43e91b0d$1@newsgroups.borland.com> <e54ku1le1ionfmrg5a3n647r7jkb55auq5@4ax.com>
In-Reply-To: <e54ku1le1ionfmrg5a3n647r7jkb55auq5@4ax.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 151.46.154.249
Message-ID: <43ea2c47$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1139420231 151.46.154.249 (8 Feb 2006 09:37:11 -0700)
Lines: 42
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news2.volia.net!border1.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail