Code::Blocks Forums

User forums => Help => Topic started by: photon3108 on May 28, 2009, 02:25:50 pm

Title: How to run a project program as lower process priority?
Post by: photon3108 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.
Title: Re: How to run a project program as lower process priority?
Post by: thomas 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.
Title: Re: How to run a project program as lower process priority?
Post by: MortenMacFly 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.
Title: Re: How to run a project program as lower process priority?
Post by: Jenna 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]
Title: Re: How to run a project program as lower process priority?
Post by: MortenMacFly 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)"
Title: Re: How to run a project program as lower process priority?
Post by: Jenna 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).
Title: Re: How to run a project program as lower process priority?
Post by: photon3108 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?
Title: Re: How to run a project program as lower process priority?
Post by: MortenMacFly 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..
Title: Re: How to run a project program as lower process priority?
Post by: photon3108 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.