0

我想运行一些定期且有一定期限的任务。我想看看 linux 调度程序 (CFS) 如何处理这些任务。我不想为此使用实时操作系统,但我想看看普通的 linux 系统如何对这些类型的工作负载做出反应,以及错过了哪些截止日期。

我该怎么做呢?

我遇到了允许类似的 SCHED_DEADLINE 。尽管它将任务视为 RT 并在作业上调用诸如 EDF 之类的 RT 调度算法。即便如此,我还是想尝试一下但失败了:

#include <sched.h>

int main ()
{
    struct sched_attr attr;
    attr.size = sizeof(struct sched_attr);
    attr.sched_policy = SCHED_DEADLINE;
    attr.sched_runtime = 30000000;
    attr.sched_period = 100000000;
    attr.sched_deadline = attr.sched_period;

    if (sched_setattr(gettid(), &attr, 0))
        perror("sched_setattr()");

    return 0;
} 

我收到此错误:

periodic-task.c: In function ‘main’:
periodic-task.c:5:20: error: storage size of ‘attr’ isn’t known
  struct sched_attr attr;
                    ^
periodic-task.c:6:21: error: invalid application of ‘sizeof’ to incomplete type ‘struct sched_attr’
  attr.size = sizeof(struct sched_attr);
                     ^
periodic-task.c:7:22: error: ‘SCHED_DEADLINE’ undeclared (first use in this function)
  attr.sched_policy = SCHED_DEADLINE;
                      ^
periodic-task.c:7:22: note: each undeclared identifier is reported only once for each function it appears in
4

0 回答 0