<p>On Windows I can do:</p>

<pre><code>HANDLE hCurrentProcess = GetCurrentProcess();

SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS);
</code></pre>

<p>How can I do the same thing on *nix?</p>

[{'answer_id': 29623, 'author': 'Silas Snider', 'author_id': 2933, 'author_profile': 'https://Stackoverflow.com/users/2933', 'pm_score': 6, 'selected': True, 'text': "<p>Try:</p>\n\n<pre><code>#include &lt;sys/time.h&gt;\n#include &lt;sys/resource.h&gt;\n\nint main(){\n    setpriority(PRIO_PROCESS, 0, -20);\n}\n</code></pre>\n\n<p>Note that you must be running as superuser for this to work.</p>\n\n<p>(for more info, type 'man setpriority' at a prompt.)</p>\n"}, {'answer_id': 30713, 'author': 'dmckee --- ex-moderator kitten', 'author_id': 2509, 'author_profile': 'https://Stackoverflow.com/users/2509', 'pm_score': 2, 'selected': False, 'text': "<p>@ allain <blockquote>Can you lower your own process' priority without being superuser?</blockquote></p>\n\n<p>Sure. Be aware, however, that this is a one way street. You can't even get back to where you started. And even fairly small reductions in priority can have startlingly large effects on running time when there is significant load on the system.</p>\n"}, {'answer_id': 60157, 'author': 'Christian', 'author_id': 4074, 'author_profile': 'https://Stackoverflow.com/users/4074', 'pm_score': 3, 'selected': False, 'text': "<p>If doing something like this under unix your want to (as root) chmod you task and set the s bit. Then you can change who you are running as, what your priority is, your thread scheduling, etc. at run time. </p>\n\n<p>It is great as long as you are not writing a massively multithreaded app with a bug in it so that you take over a 48 CPU box and nobody can shut you down because your have each CPU spinning at 100% with all thread set to SHED_FIFO (runs to completion) running as root. </p>\n\n<p>Nah .. I wouldn't be speaking from experience .... </p>\n"}]
['https://Stackoverflow.com/questions/29621', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/163/']