🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: CPU load - How can I measure it?

#4308
From: Bob Gonder
Date: Thu, 09 Feb 2006 00:14
64 lines
3315 bytes
Alberto wrote:

>> Ok, so now all of a sudden, we're working under interrupts.

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

Ok, so now not interrupts, but events.
(Next you'll tell me it's not events, but something else, so why don't
you just come out and tell us exactly what API function(s) you are
trying to use.)

>The thread is so awakened, does what it has to do, and goes back to wait for
>the next event.

"does what it has to do" could entail placing the info in a FIFO
buffer and returning.  The rest is as I described in the last message:
a workng thread that varies the complexity by the number of items in
the buffer.

Alternative (but same idea): if the events overlap, reduce the
complexity.
Have 2 (or more) threads waiting for the event, and one "busy" flag
(mutex).
Thread 1 is triggered, and sets the flag (reset upon completion).
Thread 2 is triggered, and sees flag is set, so waits for flag to
clear, and steps down complexity (probably a global value so it
"sticks")..
If a thread starts and doesn't see the "busy" flag, it could then step
up a notch (possibly to be downgraded on the next event).

You could also have the "waiting for busy" thread prod the actualy
working thread to quit early so it can start processing sooner.

The more threads you have, the bigger a performance dump you can
handle.

One more:
You can think of the event as having 2 functions:
1) start processing new data.
2) stop processing the old data, you are out of time, go back to 1.

	while( ! terminated )
	{	WaitForSingleObject( hevent, INFINITE );
nextevent:
		if( terminated )	break;

		ResetEvent();

		processlevel_1();
		if( is_signaled( hevent ) )
		{	final();
			goto nextevent;
		};
		processlevel_2();
		if( is_signaled( hevent ) )
		{	final();
			goto nextevent;
		};
		{ . . . . .}
		processlevel_N();
		final();
	};
Technical Details
Message-ID: <vpuku1lvsbv9lid301pqv91omnmpil719h@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!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> <43ea2c47$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e1eea742f875d72d
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: CPU load - How can I measure it?
Date: Wed, 08 Feb 2006 16:14:47 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <vpuku1lvsbv9lid301pqv91omnmpil719h@4ax.com>
References: <43e53514@newsgroups.borland.com> <40bcu1hlup9hqfr2qfnl6ob26jaudlqvmt@4ax.com> <43e68b34$1@newsgroups.borland.com> <bqadu11e4stdsh8bhpqblqalm6t7queu8t@4ax.com> <43e91b0d$1@newsgroups.borland.com> <e54ku1le1ionfmrg5a3n647r7jkb55auq5@4ax.com> <43ea2c47$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.69.91.178
X-Trace: newsgroups.borland.com 1139443867 69.69.91.178 (8 Feb 2006 16:11:07 -0700)
Lines: 66
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail