Search code examples
cpthreadscygwinscheduling

Unknown error when setting thread policy to SCHED_RR


I get a unknown error code (it's actually 48) when trying to set the scheduling policy to SCHED_RR for my thread.

Here is a sample of my code:

#include <sched.h>
#include <pthread.h>
#include <stdio.h>

int main() {
    pthread_attr_t attr;

    pthread_attr_init(&attr);
    pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
    int ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
    printf("ret: %s\n", strerror(ret));

    return 0;
}

Trace:

ret: Unknown error

Why is that so? It's not EPERM like I've seen in other questions.

I'm on Windows 7 using cygwin.


Solution

  • If you read the documentation of pthreads in cygwin:

    https://sourceware.org/pthreads-win32/announcement.html

    you can see that only SCHED_OTHER is supported:

    pthread_attr_setschedpolicy (only supports SCHED_OTHER)