Printing the priority of the main

被刻印的时光 ゝ 提交于 2020-08-10 18:51:32

问题


I'm wondering if there is a way to print the priority of the main. In this question I asked how to print the deafult priority of a thread; now I'm very curious to know if it's possible to do the same for the main.


EDIT: my goal is to get the priority of the unique process I created (I'm using pthread library to create threads inside the int main block). The process should not be a normal process, but a real time process, so i cannot use the getpriority function. It can be used only for normal processes (source: pag. 183, Robert Love - Linux system programming - Talking directly to the kernel and C library (2013, O'Reilly Media) 2nd Ed).

How can I get the priority of the real time process and print it?


回答1:


to print the priority of the main

getpriority can be used to query the niceness level of a process.

shed_getparam can be used to query the scheduling priority of a process.

pthread_getschedparam can be used to query scheduling priority of a thread.

How can I get the priority of the real time process and print it?

A real time process is typically understood as a process running with SCHED_FIFO or SCHED_RR scheduling policy.

You can use the same functions as above.

so i cannot use the getpriority function. It can be used only for normal processes

You can use getpriority on any process. (I think niceness level is just ignored in case of real-time scheduling, and this could be meant).



来源:https://stackoverflow.com/questions/62899868/printing-the-priority-of-the-main

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!