Pelles C forum

Pelles C => Bug reports => Topic started by: vanatic on September 16, 2018, 02:49:06 PM

Title: thrd_sleep did not sleep for .tv_sec [PellesC 9.00.9]
Post by: vanatic on September 16, 2018, 02:49:06 PM
thrd_sleep() did not sleep as expected, if .tv_sec > 0

Code: [Select]
#include <threads.h>
#include <time.h>
#include <stdio.h>

int main(void)
{
    printf("ctime: %s", ctime(&(time_t){time(NULL)}));
    printf("sleep: %d\n", thrd_sleep(&(struct timespec){.tv_sec=1}, NULL));
    printf("ctime: %s", ctime(&(time_t){time(NULL)}));
    printf("sleep: %d\n", thrd_sleep(&(struct timespec){.tv_sec=1,.tv_nsec=1}, NULL));
    printf("ctime: %s", ctime(&(time_t){time(NULL)}));
    printf("sleep: %d\n", thrd_sleep(&(struct timespec){.tv_nsec=999999999}, NULL));
    printf("ctime: %s", ctime(&(time_t){time(NULL)}));
}
Title: Re: thrd_sleep did not sleep for .tv_sec [PellesC 9.00.9]
Post by: Pelle on September 16, 2018, 07:37:45 PM
Confirmed.
Title: Re: thrd_sleep did not sleep for .tv_sec [PellesC 9.00.9]
Post by: vanatic on September 17, 2018, 05:57:10 PM
I think it is not worth to mention, but it seems the problem is in newly introduced _nanosleep(), it looks like thrd_sleep() using it  :)