gpt4 book ai didi

python - 将 python 程序设置为 SCHED_RR 或 SCHED_FIFO

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:13:17 32 4
gpt4 key购买 nike

我正在 Raspberry Pi 上运行一个 python 程序,我想将其设置为 SCHED_FIFO 或 SCHED_RR 优先级。我在网上找到了一些使用 C/C++ 执行此操作的人的信息,代码如下:

struct sched_param param;
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
sched_setscheduler(0, SCHED_FIFO, &param);

https://www.raspberrypi.org/forums/viewtopic.php?t=137341

假设这是正确的,如何在代码或终端中用 python 做这样的事情?

最佳答案

How to do something like this in python

翻译相当简单:

import os
param = os.sched_param(os.sched_get_priority_max(os.SCHED_FIFO))
os.sched_setscheduler(0, os.SCHED_FIFO, param)

关于python - 将 python 程序设置为 SCHED_RR 或 SCHED_FIFO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58176072/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com