Generating periodic workloads with deadlines in linux (NON-RT OS)

194 Views Asked by At

I want to run some tasks which are periodic and have certain deadlines. I want to see how the linux scheduler (CFS) handles these tasks. I don't want a Real-Time OS for this but I want to see how a normal linux system reacts to these kinds of workloads and what deadlines are missed.

How should I go about doing this ?

I came across SCHED_DEADLINE which allows to something similar. Although it treats the task as RT and invokes the RT Scheduling algorithms like EDF on the jobs. Even so I wanted to try this and failed :

#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;
} 

I am getting this error :

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
0

There are 0 best solutions below