File Exchange

image thumbnail

priority

version 1.5 (2.88 KB) by

Change the priority of the MATLAB Process programatically.

7 Downloads

Updated

View License

**WINDOWS only - must be compiled before use**

If you want to do some heavy processing and you don't want your computer to get all sluggish whilst it's going on, you can use this tool thusly:

pri=priority('l') % set priority to low
<do processing>
priority(pri) % set it back

Comments and Ratings (16)

Ben Mitch

Ben Mitch (view profile)

Hi Alan

1. Yes.
2. It affects child processes for priorities at normal and below; not otherwise. This is intrinsic behaviour: http://goo.gl/d7b2Wg

Thanks for your interest in priority - still in my startup script 13 years later!

Cheers

Alan

Alan (view profile)

Questions:
1. Does this still work (e.g. in 2015b? 2016a?)
2. Does this only affect the MATLAB process itself, or will it also affect any child process? (e.g. another program called via the "system" command?)

Ben Mitch

Ben Mitch (view profile)

Hi Aleksander

I wouldn't bet any money on it, but it looks like you might be compiling priority.cpp (which is C++) using a C compiler. I'd look at your mex setup options file and see if you can figure out why that's happening.

Cheers

Aleksander

Hi. i wanted to test this, however priority compile fails.

priority('compile')
Error priority.cpp: 59 illegal statement termination
Error priority.cpp: 59 skipping `char'
Error priority.cpp: 59 undeclared identifier `buf'
Error priority.cpp: 59 type error: pointer expected
Warning priority.cpp: 59 Statement has no effect
Error priority.cpp: 60 type error in argument 1 to `sprintf'; found `int' expected `pointer to char'
Error priority.cpp: 61 type error in argument 1 to `sprintf'; found `int' expected `pointer to char'
Error priority.cpp: 62 type error in argument 1 to `sprintf'; found `int' expected `pointer to char'
Error priority.cpp: 63 type error in argument 1 to `sprintf'; found `int' expected `pointer to char'
Error priority.cpp: 64 type error in argument 1 to `sprintf'; found `int' expected `pointer to char'
Error priority.cpp: 65 type error in argument 1 to `mxCreateString'; found `int' expected `pointer to const char'
Warning priority.cpp: 59 possible usage of buf before definition
Error priority.cpp: 76 illegal statement termination
Error priority.cpp: 76 skipping `int'
Error priority.cpp: 76 undeclared identifier `buflen'
Error priority.cpp: 77 illegal statement termination
Error priority.cpp: 77 skipping `char'
Error priority.cpp: 77 undeclared identifier `buf'
Error priority.cpp: 77 type error: pointer expected
Error priority.cpp: 77 operands of = have illegal types `int' and `pointer to char'
Error priority.cpp: 78 illegal statement termination
Error priority.cpp: 78 skipping `int'
Error priority.cpp: 78 too many errors

Steve Hoelzer

Steve Hoelzer (view profile)

I've been using this for many years. It's a great little tool!

Ben Mitch

Ben Mitch (view profile)

No, they don't. I've uploaded just source, then. Thanks anyway

Ben Mitch

Ben Mitch (view profile)

Hmmm... do mathworks still allows us to upload binaries? I've a funny feeling they started outlawing that. We'll see, I just tried uploading a version with a win32 binary.

Cheers

Alan

Alan (view profile)

Ben: Got it solved. It wasn't Windows 7 that was the problem. Instead, I was on 64-bit Matlab R2010b and it wanted a 64-bit binary. Recompiled it with a "mex priority.cpp" and all was working.

Side note: it is now "mex -setup", not "mex setup" as is says in your readme. Also, do you want the priority.mexw64 binary so you can include it with the distribution? Happy to share it.

Ben Mitch

Ben Mitch (view profile)

Hi Alan

Works for me on Windows 7 - what's the problem?

Perhaps you need to be an Administrator to change process priorities? Can you change the priority using Task Manager?

Alan

Alan (view profile)

Any ideas on how to get this working on Windows 7?

Ian Nauhaus

Works when I use your .dll, but I can't get the .c code to compile. I was hoping to alter your .c code to get maximum priority.

Alan

Alan (view profile)

Been using this for 9 years every day as part of my startup script so that long-running MATLAB programs don't hog my computer. Thanks!

Cleber Inacio

Good, but doesnt work on mine. I just cant set to above normal... win98 matlabR12.

E Lehmann

good work! very useful!

Y Mehta

Thanks,

It works

Ed Wilson

Nice! Confirmed to work on win2k SP3.

Updates

1.5

Added self-compile option.

1.4

Updated to provide self-compile for platforms for which binaries are not supplied.

1.3

whoops - editor, please use this file, not the one i sent five mins ago :)

1.2

2008-09-19 V2 removed restriction on "h" (high) priority as requested

1.1

Added source code, and binary for R2007b (latter uses .NET).

MATLAB Release
MATLAB 7.5 (R2007b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video