打印主优先级

编程入门 行业动态 更新时间:2024-10-12 08:21:59
本文介绍了打印主优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道是否有办法打印主的优先级.在 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_FIFO 或 SCHED_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).

更多推荐

打印主优先级

本文发布于:2023-11-25 10:32:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629403.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:优先级

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!