how to lower application priority

Hello,

I created a win2k service application.  It is a little app that writes to 2
files every 30secs.  But this thing is taking up 98% of cpu.  How do I lower
the cpu priority of appliations?

Ray

d_phi_rc@yahoo.ca


0
11/4/2003 1:01:35 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
351 Views

Similar Articles

[PageSpeed] 24

"Raymond Choy" <raymond_choy@mrcsi.com> wrote in message
news:erFp17moDHA.3256@tk2msftngp13.phx.gbl...
> Hello,
>
> I created a win2k service application.  It is a little app that writes to
2
> files every 30secs.  But this thing is taking up 98% of cpu.  How do I
lower
> the cpu priority of appliations?

Are you sitting there in a loop waiting for the 30 seconds to elapse? If so
then you should set a 30 second timer.

Cheers
Richard.


0
11/4/2003 2:01:02 AM
Raymond Choy wrote:

> Hello,
> 
> I created a win2k service application.  It is a little app that writes to 2
> files every 30secs.  But this thing is taking up 98% of cpu.  How do I lower
> the cpu priority of appliations?
> 
> Ray
> 
> d_phi_rc@yahoo.ca
> 
> 

The answer to your question is to call SetPriorityClass().  But if the 
computer has nothing better to do it will still let your app take 98% of 
the CPU.  Priority is not the same thing as CPU utilization.  Since 
writing to file generally does not take much CPU, I suggest you find out 
why your app is taking 98%.  You may have a busy loop that should be 
redesigned.

-- 
Scott McPhillips [VC++ MVP]

0
scottmcp1 (239)
11/4/2003 2:02:08 AM
If you are eating up 98% of the CPU to write to 2 files every 30 seconds, you have such
fundamental structural problems that changing the priority is not going to solve them. The
problem is that you are consuming 98% of the CPU. Fix that first. Then, and only then,
should you worry about fiddling priorities.

1. If you think you need to manipulate thread priorities, you are probably wrong
2. If you still think you need to manipulate thread priorities, you are still probably
wrong
3. If you are uttlerly convinced you need to manipulate thread priorities, feel free to do
so. You will get it wrong, but you had to try
4. If you think you have the thread priorities right, you are probably wrong.

I've manipulated thread priorities; for example, to boost the priority of a serial-port
handler so we don't get buffer overflow. It took a lot of tuning to get this to perform
well, and I consider it the absolute last resort in system architecture. Besides, you have
only limited control of the priorities anyway, so the chances that you will still have
them wrong is sitll high (I still lose tokens about once an hour, but it is a recoverable
situation. Key here is that by a +2 boost I could change the lossage from once a minute to
once an hour).

But in your case, your program is flat-out wrong. It should not be consuming 98% of the
CPU. Until you fix that problem, you are wasting your time trying other solutions.
					joe

On Mon, 3 Nov 2003 18:01:35 -0700, "Raymond Choy" <raymond_choy@mrcsi.com> wrote:

>Hello,
>
>I created a win2k service application.  It is a little app that writes to 2
>files every 30secs.  But this thing is taking up 98% of cpu.  How do I lower
>the cpu priority of appliations?
>
>Ray
>
>d_phi_rc@yahoo.ca
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
11/5/2003 5:49:53 AM
Reply:

Similar Artilces:

Application crashes on BitBlt after a while.. need help please
Hello, I call InvalidateRect() which calls OnPaint() which in turn calls a function named DrawCompass(). The application works for a while... but then crashes. It leads me to believe I have some memory leak or something not releasing resources in time. The debugger says it crashes on the statement BitBlt. Apparently it is unable to get a handle to something (i think the DC) when using BitBlt and fails an ASSERT. What am I doing wrong? Have I fogotten to delete some pointer in the code below? Can you spot anything wrong with the code below? Thank you for your time. --------------------...

Lowering quantity
i have a table containing records of different products, i have fields like name, quantity so on. i have made another table called sales, each record in this can only be for 1 record in the first table. The field in this also has quantity For each sales record how do i update the quantity of a product in the first table.. e.g. i have 15 watches & have sold 7, how do i make the number 15 automatically change to 8. Please can any1 explain to me how to do this, as simply as possible You'd have to make an update query, In the update query place the two tables you use. Join them ...

To change the application to start if i run a hyperlink
I have on a notebook a cell with a hyperklink to a image of .jpg type. When i click on hyperlink, excel (2003) run Internet Explorer 7 application, bat i want to open and to run Picture Manager application. On my desktop, for the sames conditions, run Picture Manager: Can i change on the notebook the application to open my .jpg file (Picture Manager instead I.E. 7)? Thanks for your help P.S. Scuse me for my incorrect exposure Giuseppe, Try this (For Windows XP): Open your "My computer" choose Tools / Folder Options... "File Types" tab, then select JPG files and in t...

"Microsoft CRM
Hi, What are the prerequsites for "Microsoft CRM - Application Professional" certification exam... If any one has cleared it can u guide us ? is there any sample questions or mock exams for this exam.or is there any books for this ? and is it advisable to take this exam first. Regards, ...

Error while compiling vc2005 application in vc2008
Dear Friends, The application was working fine when i complied in vc2005 on Xp.When i tried to compile the same application in vc2008 on vista .i am getting follwing errors listed below.Please help me out Error 2 error C2065: '_JBLEN' : undeclared identifier c:\users\root\desktop\header file\include \stdlib.h 1040 Error 3 error C2146: syntax error : missing ';' before identifier 'ContextRecord' c:\users\root\desktop\header file \include\winnt.h 3019 Error 4 error C4430: missing type specifier - int...

Access a regular dll using shared MFC Dll from a console application
Hi I was wondering if anyone can point me to any sample code for a console application using a regular dll using shared MFC Dll. I want to be able to use Dialogs from the MFC library for my console application. I appreciate it. Danny ...

upper to lower case
I'm new to all this, I have an Excel file and I would like to change all the previously entered characters in a column to lower case, at present they are mixed. Is it possible to do this by "find and replace"? Or is there an easier way to do it? Many Thanks for any replies. "officeworker" <officeworker@ntl.gone> wrote in message news:ZDhno.9069$dq2.5374@newsfe04.ams2... > I'm new to all this, I have an Excel file and I would like to change all > the previously entered characters in a column to lower case, at present > they are mixed. Is it ...

Setting of Tab Application
Hi all, I am trying to develop a tabbed application using windows 2000 server and VC6. It get different sizes on different System(Machine with diff. resolution) Can any one tell me, how can i adjust so that it can open on every machine of any resolution. Regards, Ghazanfar Ali Ghazanfar Ali wrote: > Hi all, > > I am trying to develop a tabbed application using windows 2000 > server and VC6. It get different sizes on different System(Machine with > diff. resolution) > Can any one tell me, how can i adjust so that it can open on every machine > of any...

Export to an Office Application
I'm try to export things from PWA to both Excel and Word, but I'm getting this error: "The ActiveX control used to export data to Word has failed to be created and this action cannot be completed." for Word and "The ActiveX control on which this reature depends cound not be created." for Excel. All other grids, charts and graphs work fine. I'm working across domains and have made the appropriate IE settings. Any suggestions on how to get the ActiveX controls to work? Thx. Put the site in your trusted sites zone, set security to low, set active X opti...

cannot display EULA......reinstall application in Money 2004
I bought a new laptop a couple of months ago. It came with MS Works including calendar, spread sheet and word processor, and Money 2005. I have MS Works Suite on my desktop with calendar, spreadsheet, Word 2002, Encarta, Streets & Trips, and Money 2004. I tried to open a Money 2004 file with 2005 without success. Since I needed to quickly access the file with the laptop, I uninstalled Mny 2005 and installed 2004 along with Streets & Trips. I have been using it with no big problems until a few days ago when I tried to open money on the laptop and got the "cannot display the...

Dynamic form, columns of subform based on a table that changes with each application
Hello! I want to make a form/subform that can be used across clinical trials. The form container for the subform won't change. However, the columns of the sub-form will change based on records in a table. I have a table of subjects with unique identifiers. I have a table of vital signs. The vitals collected for each study will be different. The vitals are collected at multiple time points. I want the subform to show the unique identifiers for the subjects as the rows and the columns to be the vital signs. Once collected on the form, I'd like to transpose the vitals into one vi...

Upgrading to lower version?
I currently have Money 2004 Premium which is going to "expire" for downloads in a couple of months. I never really needed the Premium version, which was part of a promotional, and find that the Deluxe version will do all I need. Any problem with migrating the data from a Premium version downward to the Deluxe version? -- Alan Nope. All of the Premium features are essentially external anyway. "Alan Biddle" <APBIDDLE@UNITED.NET> wrote in message news:9ofom2h5gann64rosimnjmee3bv6puur96@4ax.com... >I currently have Money 2004 Premium which is going to "expi...

Reliability of WM_COPYDATA in Processing Data between Applications,...
Hi, my questions are straight: How reliable is WM_COPYDATA if i want to send "static" data, of cource no pointers or refrences? Is there a Memory Size limitation in theory and in real life? How fast is this (sure depending on cpu, memory and allover system performance)? I never used that message before when i wanted to transfer data between applications. I always used some sort of ipc, sockets, pipes IOCTRL, etc,...since they are the best reliable methods available... Anybody has experience with this WM_COPYDATA? Regards Kerem -- ----------------------- Beste Gr�sse / Best re...

create chart from external application
Hi, I would like to know if this is possible.... I have an application that contains an hierarchical chart. I would like to export this data into a format that Visio can *understand*, and then import it into Visio and have it display in a hierarchical manner. Does any body know if this is possible to do. .....or, if there is another way of getting my data into Visio, can you please let me know. Thanks. Here is an article that describes how to automate the org chart wizard, and how to format your data: http://office.microsoft.com/assistance/2002/articles/spotlight5_July00.aspx Hope ...

Caps to lower case
Is there a way to take text that is all caps and change it to all lower case? Thanks Chris WIth formulae, using a helper column: =LOWER(A1) or via macro, in-place: http://www.mvps.org/dmcritchie/excel/proper.htm#lower In article <B5CEFEAA-73C9-43DE-8A94-24747D83B877@microsoft.com>, "Christopher Anderson" <ChristopherAnderson@discussions.microsoft.com> wrote: > Is there a way to take text that is all caps and change it to all lower case? =LOWER(A1), where the uppercase text is in A1. "Christopher Anderson" <ChristopherAnderson@discuss...

Adding additional views to SDI application
Hello. I've managed to get two views 'talking' by modifying the document and calling 'UpdateAllViews', but when I try to get the second view (a splitterwnd to a CEditView) to use the document information through CMyDoc * pDoc = GetDocument(); I get an 'unresolved external' error. I've #included the header for the additional view in the application file, and I think I know what's missing. I believe my next step is to derive a new document template class from CSingleDocTemplate to accomadate the two views in the RUNTIME_CLASS calls. So: What should I be wa...

Application slow after conversion
Hi I have converted the front end of an access 97 app into access 2000 from within access 2000. The backend is still at access 97 and needs to remain so until the conversion is complete on all client pcs. The problem is that the access 2000 version of application has gone very slow. Even a simple scroll from one record to another on a form takes several seconds. I have tried compact/repair, decompiling in access 2000, importing all objects into new access 200 db but not much difference. What is the problem and how can I fix it? Thanks Regards Here's a starting point for sorti...

Server Error in '/' Application #4
I run into this when generating any report in CRM 4.0. Object reference not set to an instance of an object. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] Micorsoft.CRM.Reporting.ReportServer.CreateCrmReportingException (ExceptioninnerException, String methodName, Int32 errorCode ) +102 The following message is one of many Stack Trace lines. Any one run into this Maybe you did not install the Reporting Connector for CRM ? Kay ...

Application becomes slow in windows server 2003
When i run my application(supports unicode) which i made in MFC(microsoft visual studio 6.0) running very slowly. While this application runs perfectly on winxp/win2000. My application open hard drive and read data from it. Please suggest how to improve the performance. Hello Ashish, Please use the MSDN forums for this, there you will find your programming experts, that maybe can have a look into your code. http://social.msdn.microsoft.com/Forums/en/categories/ Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties, and co...

Application Error (0xc0150002) "Unable to Start Correctly"
I received the above subject error message when trying to open my Money Plus Deluxe application for the first time after upgrading my OS to Windows 7 Pro, and transferring the app and files from my old XPsp3 OS back into Win 7. I've tried all the tools and options available when right clicking the Money Plus icon to no avail. All my banking accounts are in this program and its imperative I get this open and operating again. Could an MVP help? Thanks. In microsoft.public.money, Warbler wrote: >I received the above subject error message when trying to open my Money Plu...

Getting output from CreateProcess into my application...
I am using CreateProcess from within a dialog based MFC application to spawn a console program. I want to use that programs standard output to provide input to my application. I have set up the application data and create process call like so: memset(&process_info, 0, sizeof(addp_process_info)); memset(&startup_info, 0, sizeof(addp_startup_info)); /* Initialization of structures */ startup_info.cb = sizeof(startup_info); startup_info.dwFlags = STARTF_USESTDHANDLES; /* Experimental */ /* Setup a handle... */ m_hOutput = CreateFile("output.tmp", GENERIC_READ | GE...

WM_MESSAGE -- to close the application
Hi, I'm mapping a user-defined message with ON_MESSAGE(WM_ABC,OnExitABCdialog ). Then I have a user function that looks like this. long xyzView::OnExitABCdialog(UINT wParam, long lParam) { if (ABC!= NULL) { ABC->DestroyWindow(); } return 0L; } This, of course, closes the ABC dialog window. I would like to modify this, however,so that the user-function not only destroys the ABC dialog but also exits the mainframe in some cases (say, if ABC->killapp is true). That is, I want to be able to exit the application. Is there some change that I can make to the user function (s...

Buydowns
I own a retail tobacco shop and am about to go live with RMS. My question is related to the buydown feature within the pricing section of an item. In my industry it is common for the major manufacturers to run buydowns on products to facilitate discounting to the customers. Example as follows: Product = Marlboro Carton MY REGULAR COST = $30.00 MY REGULAR RETAIL = $32.00 MANUFACTURER FUNDED BUYDOWN = $5.00 > THEY NOW EXPECT MY RETAIL TO = $27.00 Problem for me is that when I lower my "Buydown" retail price, I show a loss. I am currently using another POS product t...

Convert font to lower case
I have a large spreadsheet which I am using as merge data for a letter. Some of the data is in all caps. How can I convert this to lower case? Many ways, Teri. Choose your poison: http://www.officearticles.com/excel/change_the_case_of_text_in_cells_in_microsoft_excel.htm ******************* ~Anne Troy www.OfficeArticles.com "Teri" <Teri@discussions.microsoft.com> wrote in message news:8733320F-598D-478D-8EA0-8C22DC96A701@microsoft.com... > I have a large spreadsheet which I am using as merge data for a letter. Some > of the data is in all caps. How can I convert t...

Outlook 2007
I've got problem with Outlook 2007, somehow Journal stop recording Office application but still recording email messages. I'm using Dell Inspiron XPS M1330, Win Vista Business, and Office standard 2007. OS and Office 2007 have latest updates. please help me to solve it. thanks, Rizal ...