Change priority of the current process in C

前端 未结 3 1437
别那么骄傲
别那么骄傲 2021-02-07 19:31

On Windows I can do:

HANDLE hCurrentProcess = GetCurrentProcess();

SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS);

How can I d

3条回答
  •  清酒与你
    2021-02-07 20:17

    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.

    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.

    Nah .. I wouldn't be speaking from experience ....

提交回复
热议问题