Worker thread in MDI App can only use 50% of CPU ..

Hello all,

I am working on an MDI application using VS .NET 2003.  The application 
contains a worker thread that can, if allowed run for hours and even 
DAYS.  The remainder of the application is a series of dialogs, displays 
and graph to allow the user to visually examine both the input and output 
of the worker thread.

At this time, when I run the worker thread, the Windows XP task manager 
reports that I am only using 50% of the CPU for the application.  Given 
the relatively long potential execution times of the worker thread, I 
wish to upgrade that value to at least 90% and perhaps more.

Does any one have a clue what is going on? I set the priority of the 
worker thread to "Above Normal", but that didn't effect the % CPU 
utilization of the thread. The worker thread is pure computation (i.e., a 
simulation of a physical process).  I can only assume that there is some 
"switch" in the MDI architecture that limits CPU utilization of any one 
thread to no more than a certain value.  If so, does anyone know how to 
change that setting, if it exists?

Regards,

Harvey

0
3/1/2005 1:35:22 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
757 Views

Similar Articles

[PageSpeed] 27

Harvey J Cohen wrote:

> Hello all,
> 
> I am working on an MDI application using VS .NET 2003.  The application 
> contains a worker thread that can, if allowed run for hours and even 
> DAYS.  The remainder of the application is a series of dialogs, displays 
> and graph to allow the user to visually examine both the input and output 
> of the worker thread.
> 
> At this time, when I run the worker thread, the Windows XP task manager 
> reports that I am only using 50% of the CPU for the application.  Given 
> the relatively long potential execution times of the worker thread, I 
> wish to upgrade that value to at least 90% and perhaps more.
> 
> Does any one have a clue what is going on? I set the priority of the 
> worker thread to "Above Normal", but that didn't effect the % CPU 
> utilization of the thread. The worker thread is pure computation (i.e., a 
> simulation of a physical process).  I can only assume that there is some 
> "switch" in the MDI architecture that limits CPU utilization of any one 
> thread to no more than a certain value.  If so, does anyone know how to 
> change that setting, if it exists?
> 
> Regards,
> 
> Harvey
> 

Well, there is no such limiter on CPU utilization.  A compute-bound 
thread is expected to raise utilization to 100%, even if the thread is 
low priority.  In fact, you should use low priority to keep the GUI 
responsive.

It might be useful if you temporarily change your worker thread to a 
simple do-nothing loop and see if you get 100% or not.

Things that could be reducing your utilization might be calls to Sleep, 
or I/O operations such as disk reads, or very assertive antivirus 
checkers.  You might also try breaking into your thread code a number of 
times (with the debugger) to see where it is.  You might discover it is 
frequently waiting for something.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
3/1/2005 2:00:26 AM
I noticed that too. I think it's due to the hyper threading thingie of
the pentium 4 cpu that it shows as 2 cpus, one of which is busy 100%,
while other is not. The task manager shows average.

Jan Itor

On Mon, 28 Feb 2005 19:35:22 -0600, Harvey J Cohen
<HarveyNOSPAM.Co_NOSPAM_hen@adelphNOSPAMia.net> wrote:

>Hello all,
>
>I am working on an MDI application using VS .NET 2003.  The application 
>contains a worker thread that can, if allowed run for hours and even 
>DAYS.  The remainder of the application is a series of dialogs, displays 
>and graph to allow the user to visually examine both the input and output 
>of the worker thread.
>
>At this time, when I run the worker thread, the Windows XP task manager 
>reports that I am only using 50% of the CPU for the application.  Given 
>the relatively long potential execution times of the worker thread, I 
>wish to upgrade that value to at least 90% and perhaps more.
>
>Does any one have a clue what is going on? I set the priority of the 
>worker thread to "Above Normal", but that didn't effect the % CPU 
>utilization of the thread. The worker thread is pure computation (i.e., a 
>simulation of a physical process).  I can only assume that there is some 
>"switch" in the MDI architecture that limits CPU utilization of any one 
>thread to no more than a certain value.  If so, does anyone know how to 
>change that setting, if it exists?
>
>Regards,
>
>Harvey

0
janitor1 (17)
3/1/2005 7:03:33 AM
It seems suspicious that you would want the utilization to go up. This will have a severe
negative impact on your entire system. 

The worker thread is competing with all other threads in your system. This means that it
gets whatever time is left after everyone else gets their turn. 

If you up the utilization to 90%, you are going to be very, very sorry. There are lots of
things going on in your computer that will either stop running or run so sluggishly that
they will be ineffective.

If your thread is compute bound, your app should be seeing close to 100% utliization
already. If your thread blocks for any reason (such as I/O) or has to wait for data (such
as from a network connection), then utilization will be whatever time it spends computing.

If you set priority to "above normal" then your thread will being to seriously interfere
with all other applications running on the machine, including its own GUI. 

There is no "switch" in MDI architecture, because MDI architecture is completely decoupled
from the scheduler. The scheduler sees threads. It doesn't care if the threads are running
an application that is MDI, SDI, Dialog-based, console app, or just some other worker
thread. It absolutely does not care. There is no basis for making any assumption that MDI
has anything to do with thread utilization.  

Note that if you are on a hyperthreaded processor, and the thread is using 100% of its
possible time, it will only be using 50% of the total CPU time. If you are on a true
multiprocessor, then one of your CPUs might see 100% utilization. That means that the
overall system utilization will be 50%, which is the most a single compute-bound thread
could consume on a multiprocessor.

Since you have said nothing at all about the nature of the machine it is running on, it is
hard to guess what "50%" actually means. In addition, if your thread is using 50%, what
are the threads doing that are using the other 50%? There are file system threads, the
Balance Set Manager, various device driver threads, and lots of other activities going on
which are part of the care and feeding of the operating system. 

But note that if you boost the priority, every other activiity on your CPU is going to
suffer, badly. If you are on a pure uniprocessor, you will find that you will wait many
tens of seconds just to drop down a menu (I've done this. It Is Not A Pretty Sight. It was
also a bug in my code that did it). 
					joe
 
On Mon, 28 Feb 2005 19:35:22 -0600, Harvey J Cohen
<HarveyNOSPAM.Co_NOSPAM_hen@adelphNOSPAMia.net> wrote:

>Hello all,
>
>I am working on an MDI application using VS .NET 2003.  The application 
>contains a worker thread that can, if allowed run for hours and even 
>DAYS.  The remainder of the application is a series of dialogs, displays 
>and graph to allow the user to visually examine both the input and output 
>of the worker thread.
>
>At this time, when I run the worker thread, the Windows XP task manager 
>reports that I am only using 50% of the CPU for the application.  Given 
>the relatively long potential execution times of the worker thread, I 
>wish to upgrade that value to at least 90% and perhaps more.
>
>Does any one have a clue what is going on? I set the priority of the 
>worker thread to "Above Normal", but that didn't effect the % CPU 
>utilization of the thread. The worker thread is pure computation (i.e., a 
>simulation of a physical process).  I can only assume that there is some 
>"switch" in the MDI architecture that limits CPU utilization of any one 
>thread to no more than a certain value.  If so, does anyone know how to 
>change that setting, if it exists?
>
>Regards,
>
>Harvey

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
3/1/2005 11:26:15 AM
Computational threads should be given LOW_PRIORITY. Because of Windows 
scheduler design, a runaway thread of normal priority effectively prevents 
all GUI from running (incredibly slows everything down). That problem may be 
related to a video driver design, though.

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:d8j821hgpq802pmhvrjosqk81862siker0@4ax.com...
> It seems suspicious that you would want the utilization to go up. This 
> will have a severe
> negative impact on your entire system.
>
> The worker thread is competing with all other threads in your system. This 
> means that it
> gets whatever time is left after everyone else gets their turn.
>
> If you up the utilization to 90%, you are going to be very, very sorry. 
> There are lots of
> things going on in your computer that will either stop running or run so 
> sluggishly that
> they will be ineffective.
>
> If your thread is compute bound, your app should be seeing close to 100% 
> utliization
> already. If your thread blocks for any reason (such as I/O) or has to wait 
> for data (such
> as from a network connection), then utilization will be whatever time it 
> spends computing.
>
> If you set priority to "above normal" then your thread will being to 
> seriously interfere
> with all other applications running on the machine, including its own GUI.
>
> There is no "switch" in MDI architecture, because MDI architecture is 
> completely decoupled
> from the scheduler. The scheduler sees threads. It doesn't care if the 
> threads are running
> an application that is MDI, SDI, Dialog-based, console app, or just some 
> other worker
> thread. It absolutely does not care. There is no basis for making any 
> assumption that MDI
> has anything to do with thread utilization.
>
> Note that if you are on a hyperthreaded processor, and the thread is using 
> 100% of its
> possible time, it will only be using 50% of the total CPU time. If you are 
> on a true
> multiprocessor, then one of your CPUs might see 100% utilization. That 
> means that the
> overall system utilization will be 50%, which is the most a single 
> compute-bound thread
> could consume on a multiprocessor.
>
> Since you have said nothing at all about the nature of the machine it is 
> running on, it is
> hard to guess what "50%" actually means. In addition, if your thread is 
> using 50%, what
> are the threads doing that are using the other 50%? There are file system 
> threads, the
> Balance Set Manager, various device driver threads, and lots of other 
> activities going on
> which are part of the care and feeding of the operating system.
>
> But note that if you boost the priority, every other activiity on your CPU 
> is going to
> suffer, badly. If you are on a pure uniprocessor, you will find that you 
> will wait many
> tens of seconds just to drop down a menu (I've done this. It Is Not A 
> Pretty Sight. It was
> also a bug in my code that did it).
> joe
>
> On Mon, 28 Feb 2005 19:35:22 -0600, Harvey J Cohen
> <HarveyNOSPAM.Co_NOSPAM_hen@adelphNOSPAMia.net> wrote:
>
>>Hello all,
>>
>>I am working on an MDI application using VS .NET 2003.  The application
>>contains a worker thread that can, if allowed run for hours and even
>>DAYS.  The remainder of the application is a series of dialogs, displays
>>and graph to allow the user to visually examine both the input and output
>>of the worker thread.
>>
>>At this time, when I run the worker thread, the Windows XP task manager
>>reports that I am only using 50% of the CPU for the application.  Given
>>the relatively long potential execution times of the worker thread, I
>>wish to upgrade that value to at least 90% and perhaps more.
>>
>>Does any one have a clue what is going on? I set the priority of the
>>worker thread to "Above Normal", but that didn't effect the % CPU
>>utilization of the thread. The worker thread is pure computation (i.e., a
>>simulation of a physical process).  I can only assume that there is some
>>"switch" in the MDI architecture that limits CPU utilization of any one
>>thread to no more than a certain value.  If so, does anyone know how to
>>change that setting, if it exists?
>>
>>Regards,
>>
>>Harvey
>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 


0
alegr (1131)
3/9/2005 6:43:46 AM
Reply:

Similar Artilces:

Can't get the proper display of a field in my report.
I have 2 tables, both using autonumbers for their primary key. The first table is for contacts (i.e. last name, first name, etc.). The second table is for businesses (business name, etc.) I have a field in my contacts table that has a number format so it can be used as a foreign key for the business table. I then set up the relationship between them & enforced referential integrity. When I run a query, I see the name of the business (after setting up a combo box) - no problem. When I run a report based on that query, a number is displayed (not the business name). Suggestions, pleas...

How to get TASK_ID field for summary tasks without using Project.a
I know for tasks which are not summary tasks we can get TASK_ID field using statusing web service. But i could nto find any other options than Project web service to get TASK_ID field for summary tasks and the top level project task. Problem of using Project web service is that in my custom sharedpoint web part where we are using PSI web services we get all the data required using Resource and Statusing web service for the logged in resource. But Statusing web service retrieves TASK_ID only for actual tasks and not for summary tasks. Now just to get TASK_ID of summary tas...

Outlook 2000 CPU hog
Hope one of the gurus can help me out here. Today all of the sudden I open Outlook and notice that my CPU usage is constantly pegged at 100% and stays there until I close Outlook. Is there a fix for this? TIA. Outlook 2000 SP-3 Windows XP SP2 1.6G Pentium 4 1.5G mem -- marx404 _________________ Oh, I should have checked with Slipstick first. I assume that this is the solution? http://www.microsoft.com/downloads/details.aspx?FamilyId=1E252CCF-452A-4313-A402-B50C4405580A&displaylang=en -- marx404 _________________ "marx404" <404@404.com> wrote in message news:...

2007
Project desktop expert, new to Project Server 2007 and working with a sandbox implementation currently. When I use the PWA Build Team...Replace to replace a generic resource on a project with an actual named resource after first publishing a plan, my updates don't appear to be reflected in Project Server. If I check out and open the Project Plan in MSP Pro, however, the updates were made, and then if I publish the schedule, the updates appear in server. I thought when you made resource updates using PWA that they should be reflected immediately (or as soon as the request...

Permissions is not allowing me to use my print preview.
Help! Don't understand My Permission in Excel. Even though I unrestrict, it still doesn't allow me to Preview my documents. How do I reset? Please Help, ...

With a Query in Access 2007, How can I Create This Query
I need a query that will list all records in table 1 for which there are no auditor records (Table 3). Somehow, I need to use the relationship between tables 2 and 3 to find what's not in table 1. The following query gives me a list of all records that do have auditor records. I'm at a dead end on this one. Query SELECT PTOTNamesTbl.PTOTAuditingTherapist, PTOTAuditingTherapist.PTOTFirstName, PTOTAuditingTherapist.PTOTLastName, AuditDetailInitialEval.TherapistLastName, PTOTNamesTbl.PTOTFirstName, PTOTNamesTbl.PTOTLastName, AuditDetailInitialEval.Medicare, AuditDet...

Can't send e-mails from Outlook 2003 after SP1
After installing service pack SP1 for Office 2003, I can't send e-mails anymore. They are stuck in the outbox folder. The error message states that the connection to the server was interrupted. I did not change any settings and checking them confirms that everything is as it should be. Did anyone else experience the same issue and how did you resolve it? Thanks for your help Matthias See if you can manually move those messages from your Outbox and then check all your settings again. "Mattliusa" <anonymous@discussions.microsoft.com> wrote in message news:cb7401c48a5...

Question on multiple NICs used by Exchange 2003
I have a requirement to bind four virtual SMTP servers to unique IP addresses. The server has four NICs and each IP address is uniquely bound to a virtual SMTP server. I used telnet to confirm that the appropriate virtual SMTP server responds to each assigned IP address. In case you are wondering why I did not use virtual IP addresses- Per Microsoft, the virtual IP address schema will not satisfy our requirement that the same IP address be used for sending (relaying) the e-mail that received it. Their recommendation was to have a NIC for each virtual SMTP server. The problem that I am ex...

Can Line Chart Overlaps be Highlighted?
Can the overlap portion(s) of two lines in a chart be shown in a different color, without having to manually draw a shape? I would like to show the areas where Line A is above Line B as red, and the areas where it crosses below in blue - is it possible to do this without manually drawing in shapes? Hi, To some extent it depends how many times the lines cross. If it's just the once then you can use area charts to provide the shading. http://www.andypope.info/ngs/ng21.htm http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=590 This may help if the used one line as a base line...

Developing a robust database at one co. then using it at another c
Are there any legal implications of using the type of database listed above to perform similar functions for another company? The 2 company's are in 2 totally different industries and the new database will have to be modified to fit the requirements for the industry it is in. The database was developed at the old company. there is no such thing as a robust Jet database. Move to SQL Server if you want to build a solution that will work for the next decade. Jet is and always has been depecrated On Apr 7, 12:14=A0pm, BoaMan10 <BoaMa...@discussions.microsoft.com> w...

How to use AjaxToolKit in asp.net for DHTML Editor
Dear Sir/Madam Please tell me how to use AjaxToolKit dll for DHTML purpose using C#. Thanks in Advance "Deep" <vinodkus@gmail.com> wrote in message news:7ac633e9-2cbd-4417-9b4e-363a9b5b3e74@d27g2000yqf.googlegroups.com... > Please tell me how to use AjaxToolKit dll for DHTML purpose using C#. http://tinyurl.com/ybfuqo8 ...

Using the classes created with xsd.exe
I have created classes from several xsd files. These files create about 150 classes and spot checking them they do represent types in the xsd files. the question is how do I use these files. How do I load data into them and create xml from them. Is there some articles about this subject. Thank you, -- Jerry Hi Jerry, As for the classes you've generated, are they normal classes or dataset classes? As for the normal classes you generated through xsd.exe, you can use XML serialization to convert those class instances into XML content or deserialize the XML content back into objec...

Can't sign in to 2004?
Now, another problem. I can no longer sign in with my hotmail and password if "use Money's online features that require a passport" even though I am signed on to MSN with that passport. I tried resetting the hotmail password for both MSN and Money 2004 but still can't get it to work. In microsoft.public.money, MrEKJ wrote: >Now, another problem. I can no longer sign in with my hotmail and password >if "use Money's online features that require a passport" even though I am >signed on to MSN with that passport. I tried resetting the hotmail password &...

Access violation in CDaoQueryDef::Open or CSimpleStringT::GetLength(). VC++ 6.0 app compiled in Visual C++ .NET
Hi, I have a problem using DAO in Visual C++ .net Standard edition. We have an old project created in Visual C++ 6.0 Professional. The projects compiles, links ok (with a lot of warnings telling the DAO-classes are deprecated). The compiled program executes ok until I am about to access the database. Some accesses goes ok, but some are not. It is always the same databse accesses that the program crashes on. The database that I'm using is Access 97. I also have tried converting it to 2000 and 2002. In this function the crash occurs in daocore.cpp: void CDaoQueryDef::Open(LPCTSTR lpszName...

Can't open files
Hello -- I'm sure this isn't the proper place to post my problem, but thought I'd start here anyways. Let me start off by saying that I'm extremely computer-stupid, so please forgive my ignorance. I'm running Windows Vista Ultimate, and yahoo email. For some reason, I'm unable to open attachments that have been sent to me, and saved to my computer. PLEASE HLP!! These are important documents that I really need to access. Thanks for your help -- It's not very informative to say you are not able to open attachments. What happens when you try? Is ther...

Reminders coming back after offline use
I have a user who uses Outlook on his laptop, but when he is out of the office he accesses mail through OWA. Every time he comes back in the office he says he gets inundated with old reminders popping up. And when you click on "Dismiss" you get an error that says, "conflicting edits have been made to the same item..." and there are duplicates of the event. I looked at this today and noticed that there is an event with the original date and the duplicate was showing a last-edited date of last Thursday. I asked if anything unusual happened last Thursday and he said he pro...

How to merge columns and rows into one cell besides using Merge and Center Icon?
I had posted this question before, but I couldn�t find this thread in any of the pages up till page 17. So I�m posting again. I want to merge all rows and columns starting from A1 to J2, with no lines in between into one cell. My text data value are in D1 and D2 respectively. Using Merge and Center Icon will only retain the upper-left most data, resulting the data in D2 to be deleted. So how to merge all rows and columns into one cell and yet prevent the data in D2 to be deleted? Any help will be greatly appreciated. ------------------------------------------------ ~~ Message posted from h...

Virus Outbreak by using SMTP virtual server
Hi, The client was accidentally open approved-password.zip file then the nightmare began to spread out. It will use "system administrator" and "webmaster" as sender to inform the user that their password is grant or deny. Today, it tried to send out as NDR style. I assumed the virus on the workstation is using our smtp server. Will there a log that SMTP virtual server may generate so I can keep cross reference such as workstation or username so I can pinpoint? Any suggestion or recommendation will be appreciated. I am currently using Trend Micro Offican or Scan...

Using MFC dll from non-MFC application
I have been struggling several weeks with this problem. I need to call an MFC dll from a non-MFC application. The MFC dll was originally a working MFC program that I conveted to a dll. The dll works fine except that it crashes when I exit. Can anyone provide me with some snippets of working code showing how you did this? An example of the calling code, the CWinApp (or at least the InitInstance) and the hook function would be great. I have read several times that this should be easy to do, so I am probably just missing a simple line somewhere. The way I created my dll is to use to ...

why I can not definition a variable in My Dll.
It's a dll support MFC INT __stdcall RemoterPrint() { AFX_MANAGE_STATE(AfxGetStaticModuleState()) int kkkkkkkk=0; INT booklet1 = 1; INT Pages1 = 0; INT m_FileID = ::InitUMFFile(szFilePathName);//Insert Breakpoint; ........... } I found the value is as follows kkkkkkkk 18072928 booklet1 -858993460 Pages1 -858993460 why ???? I am really puzzled. I added someting in stdafx.h #include <queue> #include<stack> using namespace std; "zhang" <makefriend8@163.com> д����Ϣ����:u1SbT%23FbHHA.4656@TK2MSFTNGP03.phx.gbl... > It's a dll support MFC ...

How can I change order of pages in a fold brochure in publisher
When I work on the pages on the screen it shows pages 2 & 3 and the page preview shows 2 & 3 but when I go to print page 3 comes out as page 5. Is your publication setup as a booklet? When you go to print are you checking current page or typing the page number? What version Publisher are you using? "JudieM" wrote: > When I work on the pages on the screen it shows pages 2 & 3 and the page > preview shows 2 & 3 but when I go to print page 3 comes out as page 5. "Mary Sauer" wrote: > Is your publication setup as a booklet? When you go to prin...

Ctrl that can have focus, and paint
Hi, Could anyone suggest to me a suitable control for use on a dialog that can get focus, recieve all of the keyclicks (including up / down etc), but also support full custom painting? I tried a CEdit but typing overrides my painting. - Mark R That's a loaded question. But you can inherit from CWnd, or you can even inherit from CStatic if you wanted. You will have to catch the WM_CHAR for some keys, and WM_KEYDOWN for others like the arrows. AliR. "Mark Randall" <markyr@REMOVETHISgoogle.ANDTHIScom> wrote in message news:uZtdckNGFHA.4004@tk2msftngp13.phx.gbl... &g...

Exchange 2003 can't connect to SMTP on internal IP address
We have Exchange 2003 server no service packs. This has 2 IP addresses used for SMTP. We were looking to lockdown our Exchange server to only allow mail from our email provider. After setting this up we thought it would be better to do this at the firewall level, so we undid the changes we made. The changes were as follows: Created a global accept list Created a global deny list Created connection filter to an SMTP virtual server No reboot took place during this. When undoing the change we removed the IP list before the virtual SMTP server. This may have caused the problems out...

how can i write arabic in Excel?
I already installed MS Office and i can write arabic in the word but when i try to use the excel, i can't write arabic, so please can you tell me what is the proplem and how i can solve it. I write arabic in excel done, have you already activate your win2000 or higher for the regional options> language > .... and you can add the arabic language for this option -- hni ------------------------------------------------------------------------ hni's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28451 View this thread: http://www.excelforum.com/showthr...

Can you have both Office 2004 and Office 2008 on your computer?
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel I was wondering before I install Office 2008 if I can keep Office 2008 on my computer as well. I know you can do this with the windows versions (office 2003 and office 2007). On 3/28/08 11:51 00AM, in article ee967d0.-1@webcrossing.caR9absDaxw, "mlejay@officeformac.com" <mlejay@officeformac.com> wrote: > > I was wondering before I install Office 2008 if I can keep Office 2008 on my > computer as well. I know you can do this with the windows versions (office > 2003 and office 2007). I'm s...