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)

ke 19. kesäk. 2019 klo 19.01 Mehdi Sabwat ([email protected]) kirjoitti:
>
> Hi,
>
> Can anyone help me out ?
>
> Thanks !
> Regards
>
> On Mon, Jun 17, 2019 at 5:16 PM Mehdi Sabwat <[email protected]> wrote:
>>
>> Also:
>> https://github.com/emscripten-core/emscripten/pull/8662
>>
>> does this mean the syscall won't be supported?
>>
>> On Mon, Jun 17, 2019 at 5:12 PM J Decker <[email protected]> wrote:
>>>
>>> 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;
>>> },
>>> ```
>>>
>>>
>>> On Mon, Jun 17, 2019 at 7:53 AM Mehdi Sabwat <[email protected]> wrote:
>>>>
>>>> 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?
>>>>
>>>> https://code.videolan.org/snippets/982
>>>>
>>>> it seems it is implemented: 
>>>> https://github.com/emscripten-core/emscripten/blob/incoming/system/lib/libc/musl/src/time/clock_nanosleep.c
>>>>
>>>> can you please help me figure out how to integrate it?
>>>>
>>>> Thank you !
>>>>
>>>> At your disposal for more info. if needed
>>>>
>>>> Regards,
>>>>
>>>> --
>>>> 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 [email protected].
>>>> 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.
>>>
>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/emscripten-discuss/CAA2GJqXD163B4DwA-JcBQx-G_xXAbYcYo3FuX5dhbz__2w_AaA%40mail.gmail.com.
>>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 [email protected].
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CA%2B6sJ-2%3DNAmMaTPweV%2Bt7NXTjsW4CKJsU%3DvtBbj5iFwXssyZMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to