insane-adding-machines / frosted

Frosted: Free POSIX OS for tiny embedded devices
GNU General Public License v2.0
215 stars 39 forks source link

implement nanosleep() #117

Closed nathanLoretan closed 7 years ago

nathanLoretan commented 7 years ago

Hello, the function nanosleep() always returns -1. To try, I call a function that executes a simple loop within I wait 1s. But the function is always interrupted and it returns -1.

 int i, ms;
 struct timespec    req;

 ms = 1000;

 for(i = 0; i < 5; i++) {
        printf("Counter %d\n\r", i);
        req.tv_sec = 1000 / 1000;
        req.tv_nsec = (1000 % 1000) * 1000000;
        nanosleep(&req, 0);   
 }
danielinux commented 7 years ago

Nanosleep is not yet implemented (it's a stub in the libC that returns -1 and sets errno to ENOSYS).

danielinux commented 7 years ago

This should be fixed now.

Please test with latest toolchain from http://archive.trexotech.com and the newest kernel.

nathanLoretan commented 7 years ago

I've tested but the time defined in second into the struct timespec is not used.

danielinux commented 7 years ago

My bad, there was a typo in the implementation. Should be fixed by the new toolchain (currently compiling, will be on the archive soon)

danielinux commented 7 years ago

@nathanLoretan please try with latest toolchain http://archive.trexotech.com:8081/

nathanLoretan commented 7 years ago

It works, thank you.