- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下代码有效并需要“root”身份验证:
struct sched_param param;
param.sched_priority = 99;
if (sched_setscheduler(0, SCHED_FIFO, & param) != 0) {
perror("sched_setscheduler");
exit(EXIT_FAILURE);
}
但是,这个似乎可以工作(没有错误)但没有任何效果并且不需要“root”身份验证:
struct sched_param param;
param.sched_priority = 99;
sched_setscheduler(0, SCHED_FIFO, & param);
为什么?我用 gcc/Ubuntu 13 编译。
最佳答案
很可能 sched_setscheduler
在您的第二个示例中不起作用。您只是忽略了可能不是 0
的返回值。
由于您忽略了返回值,您实际上并不知道它是否有效。
查看 sched_setscheduler
的手册页,您会在 RETURN VALUE 下找到它
RETURN VALUE
On success, sched_setscheduler() returns zero.
On success, sched_getscheduler() returns the policy for the process (a nonnegative integer).
On error, -1 is returned, and errno is set appropriately.
如果返回 -1
,则设置 errno 并且 perror 打印一个人类可读的错误字符串。
既然你说 -1
是从第二个例子中返回的,sched_setscheduler
实际上并没有起作用。
关于c - 为什么 sched_setscheduler() 如果没有包含在 if block 中则不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16502054/
如何使用此 topic 中解释的 sched_setscheduler ?看来我得写个C代码,在shell上运行? 最佳答案 要从 shell 更改进程的策略,您需要使用 chrt .要选择实时优先级
我有以下源,它喜欢 SCHED_RR 优先级 90: int main(int argc, char** argv) { const char *sched_policy[] = {
我是操作系统编程新手。因此,我编写了这段代码来更改后台进程的调度策略,我通过命令行参数提供了其进程 ID,但 sched_setscheduler() 函数失败,给出错误“函数未实现” #includ
我对 sched_setscheduler() 在 Linux 中的工作方式感到困惑。 我的理解是 Linux 在内部使用 CFS (SCHED_NORMAL) 进行内核进程调度。当用户空间启动一个程
我有一个调用 sched_setscheduler(pid, SCHED_RR, ... ) 的 C++ 应用程序。 该应用程序以 root 权限在 Linux 上运行。通话通常有效。只有在一个特定的
为什么 sched_setscheduler() 需要根权限? 我正在编写一些受益于设置 SCHED_FIFO 的代码。但是如果我使用 sched_setscheduler() 我现在必须要求这个进程
以下代码有效并需要“root”身份验证: struct sched_param param; param.sched_priority = 99; if (sched_setscheduler(0,
我需要为 Linux 提供 P/Invoke 签名 sched_setaffinity函数,从在 Mono 上运行的 C# 代码调用。 int sched_setaffinity(pid_t pid,
只是尝试使用 SCHED_FIFO 策略将调度优先级设置为最大。在我安装 libpam-systemd 后,这段代码开始抛出错误。 编辑:归结为下面的两个问题,尽可能把它们说清楚。 追踪: sched
我是一名优秀的程序员,十分优秀!