[Bug 249469] [linuxlator] linux_sched_setscheduler fails: Operation not permitted

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Feb 4 04:13:41 UTC 2021


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=249469

--- Comment #3 from Alex S <iwtcex at gmail.com> ---
(In reply to Edward Tomasz Napierala from comment #2)

% cat sched.c 
#define _GNU_SOURCE

#include <assert.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>

void* thread_start(void* arg) {
  return 0;
}

int main() {

  {
    pthread_attr_t attr;
    assert(pthread_attr_init(&attr) == 0);
    assert(pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0);

    pthread_t t;
    int err = pthread_create(&t, &attr, &thread_start, NULL);
    if (err != 0) {
      fprintf(stderr, "pthread_create: %s\n", strerror(err));
    }

    pthread_attr_destroy(&attr);
  }

  {
    struct sched_param p;
    p.sched_priority = 0;
    if (sched_setscheduler(0, SCHED_RESET_ON_FORK, &p) == -1) {
      perror("sched_setscheduler");
    }
  }

  {
    struct rlimit rl;
    int err = getrlimit(RLIMIT_RTTIME, &rl);
    if (err == -1) {
      perror("rlimit");
    }
  }

  return 0;
}
% /compat/linux/bin/gcc sched.c -pthread -o sched
% ./sched 
pthread_create: Operation not permitted
sched_setscheduler: Invalid argument
rlimit: Invalid argument

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-emulation mailing list