Reply
Thread Tools
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#1
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's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#2
@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 ...
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature
 
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#3
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.
__________________
Русский военный корабль, иди нахуй!
 
Posts: 1,808 | Thanked: 4,272 times | Joined on Feb 2011 @ Germany
#4
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().
 

The Following 6 Users Say Thank You to reinob For This Useful Post:
Posts: 324 | Thanked: 739 times | Joined on Jun 2009 @ São Paulo, Brazil
#5
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.
 
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#6
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!
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature

Last edited by peterleinchen; 2014-11-06 at 13:06.
 

The Following 3 Users Say Thank You to peterleinchen For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#7
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.
__________________
Русский военный корабль, иди нахуй!

Last edited by pichlo; 2014-11-06 at 13:14.
 

The Following 3 Users Say Thank You to pichlo For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 21:42.