EMSCRIPTEN and clock_nanosleep

50 views
Skip to first unread message

Mehdi Sabwat

unread,
Jun 17, 2019, 10:53:14 AM6/17/19
to emscripten-discuss
Hello,

I would like to understand how EMSCRIPTEN integrates musl/it's own implementation of libc.

I am trying to make a minimal example work, will you please help me figure out, what I am missing?



can you please help me figure out how to integrate it?

Thank you !

At your disposal for more info. if needed

Regards,

J Decker

unread,
Jun 17, 2019, 11:12:58 AM6/17/19
to emscripten-discuss
There is https://github.com/kripken/emscripten/issues/5518   Implement clock_nanosleep function


https://github.com/kripken/musl-emscripten/blob/emscripten/src/time/clock_nanosleep.c  looks like there's a supported syscall


emsdk\emscripten\1.38.32\system\lib\clock_nanosleep.c ... but there's a 'libc.symbols' (in just 1.38.32) which only has nanosleep and no clock_nanosleep


there is 1.38.32/src which has library_syscall.js   
```
__syscall265: function(which, varargs) { // clock_nanosleep 
#if SYSCALL_DEBUG
     err('warning: ignoring SYS_clock_nanosleep');
 #endif
     return 0;  
},
```


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/82a2c072-f47d-4604-8390-4b71157099b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mehdi Sabwat

unread,
Jun 17, 2019, 11:17:20 AM6/17/19
to emscripte...@googlegroups.com

Mehdi Sabwat

unread,
Jun 19, 2019, 12:01:45 PM6/19/19
to emscripte...@googlegroups.com
Hi,

Can anyone help me out ?

Thanks !
Regards

Jukka Jylänki

unread,
Jun 19, 2019, 3:48:01 PM6/19/19
to emscripte...@googlegroups.com
If you want to perform a sleep, in singlethreaded builds an on the
main thread, the only proper way is to yield control flow back to the
browser. In multithreaded builds inside a pthread (web worker) you can
use emscripten_thread_sleep() function to do a synchronous sleep,
check out https://github.com/emscripten-core/emscripten/blob/7224b7930ec2a6abca332300e247619e1aea1719/system/include/emscripten/threading.h#L318
.

If the application is not particularly dependent on native
performance, then either emterpreter or asyncify build modes can be
used to more or less emulate CPU execution/mitigate the call flow
issue, though these come with drawbacks.

Currently sleeping is not implemented as a syscall, but in pthreads
enabled builds those could be implemented backed on top of
emscripten_thread_sleep() (though only for pthreads and not the main
thread)
> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CANLCaym5wZ8rqU6LAthKBi5FapM03m5tJ%3DOYevMHdp%2Be%3D4%3DB%2Bg%40mail.gmail.com.

Mehdi Sabwat

unread,
Jun 23, 2019, 2:06:30 PM6/23/19
to emscripte...@googlegroups.com
Reply all
Reply to author
Forward
Message has been deleted
0 new messages