Author Topic: How to run a project program as lower process priority?  (Read 5072 times)

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
How to run a project program as lower process priority?
« on: May 28, 2009, 02:25:50 pm »
In windows I can use start /belownormal to make the program runing at belownormal priority.

Is there any methods like this in code::blocks? Just the project program need it.

Code::blocks runs at normal priority.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: How to run a project program as lower process priority?
« Reply #1 on: May 28, 2009, 03:04:12 pm »
There's no such thing at the present time, and it's probably not easy to implement either, as wxExecute doesn't provide a means to control the process priority.

You can work around it if you must, by running your program as post-build step like this:
cmd /c start /belownormal yourprogram.exe

It may be possible to build this functionality into consolerunner by having consolerunner change its own priorty before starting the process, however this won't work with GUI programs then, as these are launched by Code::Blocks directly.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: How to run a project program as lower process priority?
« Reply #2 on: May 28, 2009, 03:09:09 pm »
cmd /c start /belownormal yourprogram.exe
Maybe not as post-build step but as tool. This way you can run *any* project / target executable with lower priority if you use the provided macros correctly.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to run a project program as lower process priority?
« Reply #3 on: May 28, 2009, 03:10:45 pm »
You can work around it if you must, by running your program as post-build step like this:
cmd /c start /belownormal yourprogram.exe
You can also configure a tool to start the targets executable at low-priority.
See the attached screenshot.

EDIT:
crossed with MortenMacFly's post


[attachment deleted by admin]
« Last Edit: May 28, 2009, 03:40:13 pm by MortenMacFly »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: How to run a project program as lower process priority?
« Reply #4 on: May 28, 2009, 03:40:49 pm »
EDIT:
crossed with MortenMacFly's post
Hehe...

Notice that you need to replace the "TARGET" string with the targets' name. So a for a target named "debug" it should look like this then:
"$(DEBUG_OUTPUT_FILE)"
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to run a project program as lower process priority?
« Reply #5 on: May 28, 2009, 03:46:35 pm »
EDIT:
crossed with MortenMacFly's post
Hehe...

Notice that you need to replace the "TARGET" string with the targets' name. So a for a target named "debug" it should look like this then:
"$(DEBUG_OUTPUT_FILE)"

Works correctly here for any targets (except virtual targets of course).

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: How to run a project program as lower process priority?
« Reply #6 on: May 29, 2009, 10:27:49 am »
Thanks everyone.

That's great. It works. When the program is running (1 hr), I can write some codes in other projects and it doesn't block cpu.

But I have a new problem. When I used "Tool" like everybody said, the program didn't search necessary dlls in other projects.
Actually I don't understand how does code::blocks search dlls which the project program links. I just set "project build options" -->
"search directories" --> "linker" where dlls is and don't need change "execution working dir" to the dll's directory. It works well at
svn 5535.

I tried to set executable: PATH=%PATH%;c:\projects_cb\abc\dll & cmd /c start /belownormal in "Tool". It didn't work. How can
I solve it?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: How to run a project program as lower process priority?
« Reply #7 on: May 29, 2009, 04:42:16 pm »
I tried to set executable: PATH=%PATH%;c:\projects_cb\abc\dll & cmd /c start /belownormal in "Tool". It didn't work. How can
I solve it?
Setup the path environment variable "PATH" accordingly using the evvars plugin and a specific setup for your project..
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: How to run a project program as lower process priority?
« Reply #8 on: May 31, 2009, 10:23:56 am »
I clone the default and add PATH(key)/c:\dlls(value) in environment variables.
And then I select the new one which cloned from the default in project --> EnvVar Option.

When I use "Tool", It doesn't still find the dll.