0

I am assigning sched_deadline policy in a thread via the following code:

  struct sched_attr attr;
  memset(&attr, sizeof(struct sched_attr), 0);
  attr.size = sizeof(struct sched_attr);
  attr.sched_policy = SCHED_DEADLINE;
  attr.sched_runtime = runtime;
  attr.sched_deadline = period;
  attr.sched_period = period;

  int ret = syscall(SYS_sched_setattr, 0, &attr, 0);
  if(ret == -1) {
    perror("Error in syscall");
    pthread_exit(NULL);
  }

This works fine, but the program can only run with sudo. Whenever, I execute it normally, it fails. I am expecting this happens because of the syscall. Is there any way to avoid using sudo for this. There are no wrappers available for this syscall of SCHED_DEADLINE yet in Linux.

soham
  • 1,508
  • 6
  • 30
  • 47

0 Answers0