gpt4 book ai didi

multithreading - 在Linux内核中,以下方式创建实时kthread是否正确?

转载 作者:行者123 更新时间:2023-12-01 10:01:05 26 4
gpt4 key购买 nike

在 Linux 内核中,线程调度分为实时调度(如 SCHED_FIFO)和普通调度(SCHED_NORMAL)。
如果我想创建一个实时线程,该怎么做?我想像:

1,kthread_create

2,give the thread a real time scheduler

3,assign a real time priority


这对实时 kthread 有用吗?

最佳答案

在线程本身中,调用:

struct sched_param param = { .sched_priority = prio };
sched_setscheduler(current, SCHED_FIFO, &param);

哪里 prio是你想要的优先级。

关于multithreading - 在Linux内核中,以下方式创建实时kthread是否正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16042123/

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