打印 main 的优先级

Printing the priority of the main

我想知道是否有办法打印主程序的优先级。在 问题中,我询问了如何打印线程的默认优先级;现在我很好奇是否可以对主程序执行相同的操作。


编辑:我的目标是获得我创建的唯一进程的优先级(我使用 pthread 库在 int 主块内创建线程)。该进程不应该是一个正常进程,而是一个实时进程,所以我不能使用 getpriority 函数。它只能用于正常进程(来源:第 183 页,Robert Love - Linux system programming - Talking directly to the kernel and C library (2013, O'Reilly Media) 2nd Ed).

如何获取实时进程的优先级并打印出来?

to print the priority of the main

getpriority可用于查询进程的niceness级别。

shed_getparam可用于查询进程的调度优先级

pthread_getschedparam可以查询线程的调度优先级

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

实时进程通常被理解为进程运行SCHED_FIFOSCHED_RR调度策略。

您可以使用与上述相同的功能。

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

您可以在任何进程上使用 getpriority。 (我认为在实时调度的情况下,niceness level 被忽略了,这可能是这个意思)。