Process priority and procesor usage

  • Thread starter Thread starter New_at_CF
  • Start date Start date
N

New_at_CF

I have 2 applications. One is for navigation and uses a lot of
processor time.
My other application is using serial port to communicate to hardware
device.

When navigation is running and calculating my hardware is breaking....

Is it possible to set my application higher priority than navigation
or to set maximum percent of
processor it can use?


Is there some better solution?


Thank you,

New_at_CF
 
There's no such thing as an application priority. You can set thread
priority for the current thread using CeSetThreadPriority() (P/Invoke it;
the C declaration should be in the SDK for your target device). Note,
however, that higher-priority processes will always run, assuming they're
ready, before lower priority ones, so you have to be careful not to starve
other threads. It sounds to me like you haven't thought about properly
sharing the processor in the design of your code; you have to go back and do
that.

Paul T.
 
There's no such thing as an application priority. You can set thread
priority for the current thread using CeSetThreadPriority() (P/Invoke it;
the C declaration should be in the SDK for your target device). Note,
however, that higher-priority processes will always run, assuming they're
ready, before lower priority ones, so you have to be careful not to starve
other threads. It sounds to me like you haven't thought about properly
sharing the processor in the design of your code; you have to go back and do
that.

Paul T.


My application is communicating with one hardware device (serial port)
and procesing receved data.
I communicate in cycle every 100 ms.
Application works great until routing starts in oither application
(Maporama DriveME).
Problem is that i don't have any influence to Maporama and it works
how it works.

New_at_CF
 
OK, question #1 is "why?" Why do you care how often you read from the port?
It seems to me, again, that you have not actually designed your application,
but have somehow allowed it to grow such that you are dependent on a cycle
time in some loop, which is obviously a bad design. As I previously
indicated, you can set the thread priority of your communication thread
(you're surely not reading from the serial port in your UI thread, right?),
to something higher and carefully construct it so that it's more-important
than whatever this other software is doing.

Paul T.
 
Back
Top