sem_timedwait causes "The futex facility returned an unexpected error code"

1k views Asked by At

What is wrong with this code? When the sem object is posted, it is fine. However as soon as it needs to wait for the time out, I get "The futex facility returned an unexpected error code".

void* BackgroudProc(void*){
    struct timespec ts;
    while(1){
        clock_gettime(CLOCK_REALTIME, &ts);
        ts.tv_sec += 10;
        sem_timedwait(&hFCRequestEvt, &ts);
        for(int i = 0; i < requests.size(); i++){
            if(numOfConnection >= MAX_CONNECTION)
                break;
            if(requests[i].state == QUEUED){
                requests[i].state = STARTED;
                numOfConnection++;
                pthread_create(&requests[i].tid, 0, (void* (*)(void*))FileCopyFSM, (void*)(&requests[i]));
            }
        }
    }
}
0

There are 0 answers