maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [M5] What can *my app* do to stop the watchdog kicking in? (https://talk.maemo.org/showthread.php?t=94112)

pichlo 2014-11-06 10:27

What can *my app* do to stop the watchdog kicking in?
 
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.

peterleinchen 2014-11-06 12:30

Re: What can *my app* do to stop the watchdog kicking in?
 
@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 ...

pichlo 2014-11-06 12:39

Re: What can *my app* do to stop the watchdog kicking in?
 
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.

reinob 2014-11-06 12:45

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

Originally Posted by pichlo (Post 1446136)
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().

traysh 2014-11-06 12:46

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

Originally Posted by pichlo (Post 1446136)
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.

peterleinchen 2014-11-06 12:51

Re: What can *my app* do to stop the watchdog kicking in?
 
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!

pichlo 2014-11-06 12:55

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

Originally Posted by traysh (Post 1446138)
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.

Quote:

Originally Posted by reinob (Post 1446137)
$ man sched_yield

Thanks, exactly what I needed. Going to give it a try.

EDIT:
Quote:

Originally Posted by peterleinchen (Post 1446142)
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.


All times are GMT. The time now is 13:33.

vBulletin® Version 3.8.8