打印主优先级 [英] Printing the priority of the main

查看:63
本文介绍了打印主优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法打印主的优先级.在 this 问题中,我问了如何打印线程的默认优先级;现在我很想知道是否可以对 main 做同样的事情.

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.

我的目标是获得我创建的唯一进程的优先级(我使用 pthread 库在 int 主块内创建线程).该进程不应该是一个正常进程,而是一个实时进程,所以我不能使用 getpriority 函数.它只能用于普通进程(来源:第 183 页,Robert Love - Linux 系统编程 - 直接与内核和 C 库对话(2013,O'Reilly Media)第 2 版).

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?

推荐答案

打印主线程的优先级

to print the priority of the main

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

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

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

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

pthread_getschedparam 可用于查询线程的调度优先级.

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?

实时进程通常被理解为使用 SCHED_FIFOSCHED_RR 调度策略运行的进程.

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.

所以我不能使用 getpriority 函数.只能用于正常进程

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

您可以在任何进程上使用 getpriority.(我认为在实时调度的情况下只是忽略了 niceness 级别,这可能意味着).

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).

这篇关于打印主优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆