Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    What can *my app* do to stop the watchdog kicking in?

    Reply
    pichlo | # 1 | 2014-11-06, 10:27 | Report

    I am talking about the app that I am developing. Some operations can take a vvvveeeeerrrrrryyy long time (up to a few minutes) and the damn watchdog just reboots the damn phone. I know about the R&D mode (BTW, it seems all the links to the R&D mode wiki page are dead) but I cannot ask the users of my app to enable the R&D mode just to be able to use it, can I?

    I assume there is a system call somewhere that I can call periodically to reset the watchdog. What is it?

    Sorry if this is a silly question with an obvious answer. I must be particularly slow this morning. I just spent two hours searching and found nothing of relevance.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    peterleinchen | # 2 | 2014-11-06, 12:30 | Report

    @pichlo
    Huh, what kind of app is 'that'? Taking all resources away?
    Did you try with 'nice -n 19 app'?
    Or maybe if it is IO consuming, then 'nice -n 19 ionice -c 3 -n 7 app'?

    Hope this is sufficient to let the watchdog bite/kick in.

    About wtachdog calls from within app IDK ...

    Edit | Forward | Quote | Quick Reply | Thanks

     
    pichlo | # 3 | 2014-11-06, 12:39 | Report

    It is a GUI app that, depending on settings, may want to fill up a large (200MB+) buffer with data generated at runtime. In pseudocode...
    Code:
    for (int i; i < 200MB; ++i)
      buffer[i] = fx(i);
    fx() can be quite a complex function and running it 200M times can take up to a few minutes.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    reinob | # 4 | 2014-11-06, 12:45 | Report

    Originally Posted by pichlo View Post
    It is a GUI app that, depending on settings, may want to fill up a large (200MB+) buffer with data generated at runtime. In pseudocode...
    Code:
    for (int i; i < 200MB; ++i)
      buffer[i] = fx(i);
    fx() can be quite a complex function and running it 200M times can take up to a few minutes.
    $ man sched_yield

    add #include <sched.h>

    and do something along the lines of:

    Code:
    for (int i; i < 200MB; ++i) {
      if(i % 1000 == 0) sched_yield();
      buffer[i] = fx(i);
    }
    If that's too ugly for you you could measure the elapsed time (at every iteration, or after N interations) and only when the time is greater than some threshold, you call sched_yield().

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 6 Users Say Thank You to reinob For This Useful Post:
    Estel, foobar, juiceme, peterleinchen, pichlo, wicket

     
    traysh | # 5 | 2014-11-06, 12:46 | Report

    Originally Posted by pichlo View Post
    It is a GUI app that, depending on settings, may want to fill up a large (200MB+) buffer with data generated at runtime. In pseudocode...
    Code:
    for (int i; i < 200MB; ++i)
      buffer[i] = fx(i);
    fx() can be quite a complex function and running it 200M times can take up to a few minutes.
    Do the complex job in another thread.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    peterleinchen | # 6 | 2014-11-06, 12:51 | Report

    Yes, that will let the WD bite, for sure!

    Did you try above suggestion?
    May slow down a bit more, but for sure should leave enough resources to let the WD kick...

    @was/am on slow line: that would have been my next suggestion: a sleep inside the loop every 100th call or so. But reinob gave already the (better) idea!

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by peterleinchen; 2014-11-06 at 13:06.
    The Following 3 Users Say Thank You to peterleinchen For This Useful Post:
    Estel, pichlo, reinob

     
    pichlo | # 7 | 2014-11-06, 12:55 | Report

    Originally Posted by traysh View Post
    Do the complex job in another thread.
    It is already in another thread. If you mean creating a new thread each time I call fx(), then no, thank you.

    Originally Posted by reinob View Post
    $ man sched_yield
    Thanks, exactly what I needed. Going to give it a try.

    EDIT:
    Originally Posted by peterleinchen View Post
    a sleep inside the loop every 100th call or so
    That's also not bad. I would call it every Nth second instead of every Nth loop but the idea is sound, thanks.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by pichlo; 2014-11-06 at 13:14.
    The Following 3 Users Say Thank You to pichlo For This Useful Post:
    Estel, peterleinchen, reinob

     
vBulletin® Version 3.8.8
Normal Logout