PDA

View Full Version : Possible to turn off watchdog timer on simulator?




haploidus
Apr 6, 2009, 04:03 PM
Hi,

I have a test program with some printf output. And it works well on real iPhones. However, it has encountered a program if runs on Simulator.

It is simply terminated by simulator after 20 seconds. I believe this is because of the watchdog timer which suppose to terminate the program which spends too much time to load. This timer works well on the device which lets my program go on, but it doesn't work so well on the simulator.

My question is that is there a way to turn this timer off on the simulator?

Thanks



dejo
Apr 6, 2009, 04:19 PM
So, your app takes longer to start up in the simulator than it does on an actual device? If so, wow! Something must be seriously wrong with your app then. What are you doing during the startup?

haploidus
Apr 6, 2009, 04:24 PM
No, my program doesn't take time to 'load' actually. It just keeps running and print out something.

I guess the problem is that the simulator wrongly thinks it's loading, but iphone doesn't think so. That's why it behaves differently on two platforms.

Jeremy1026
Apr 6, 2009, 04:39 PM
As long as it works on the device, it doesn't really matter what happens on the simulator. If it was the other way around then you would have something to worry about.

dejo
Apr 6, 2009, 04:40 PM
It just keeps running and print out something.
Where are you doing this printing? And perhaps it is running so fast on the simulator, you are overflowing a buffer or something.

haploidus
Apr 6, 2009, 04:45 PM
I see the printf on Console window. Its behaves consistently, terminated at 20 seconds, and if I make it running shorter than 20 seconds, no any problem.

The problem is my client asks for this program working on the simulator.

If not possible to turn off the timer, is this any way to tell the simulator I am not loading?

dejo
Apr 6, 2009, 04:53 PM
I see the printf on Console window.
Yes, but how often is this printf getting called? And where in the code are you looping?

haploidus
Apr 7, 2009, 08:38 AM
Well, my program is just a faceless console program with many standard printf in between. The output will be seen on Console window when run the program with the simulator.

When I run it, it stops at 20th second every time. And If I cut my program into smaller pieces (meaning can finish running within 20 seconds) and run them piece by piece, no problem at all. That's why I think it is a watchdog timer issue. I don't think it is the matter of printf itself.

jnic
Apr 7, 2009, 09:56 AM
I think dejo's asking where you're calling printf. If it's just straight in a for loop with no manual delays, then it's likely to run extremely fast in simulator (much faster than on the device) and fill up a memory buffer somewhere which will cause it to fault and be killed.

haploidus
Apr 7, 2009, 10:00 AM
Thanks. I know what he was asking, but I just don't think that is the problem.

Because as long as I cut the program short (within 20 seconds), without changing printf positions, the program, as well as printfs, will works fine.

One more evidence is that the program is always terminated at 20th second, when I add or remove some code, it will be terminated at a different place. And more interestingly, I have several printf and operations in a for loop, the program NEVER stops inside the for loop. Like following:

for (i = 0; i < 100; i++)
{
printf("i = %d", i);
...
print(" 1");
...
print(" 2");
...
print(" 3\n");
}

when the program is terminated, the display will be

i = ...
i = 87 1 2 3

The 87 can change if I add or move something from the code, but you won't see things like

i = 56 1 2

jnic
Apr 7, 2009, 10:02 AM
Thanks. I know what he was asking, but I just don't think that is the problem.

Because as long as I cut the program short (within 20 seconds), without changing printf positions, the program, as well as printfs, will works fine.

Right, because (according to this theory) it takes 20 seconds to fill the buffer, so stopping before then won't trigger the problem.

dejo
Apr 7, 2009, 10:06 AM
I'd suggest moving the printf's out of the application loading code and into some separate place, perhaps using an NSTimer from the main view controller.

PhoneyDeveloper
Apr 7, 2009, 10:32 AM
The answer to your question is NO. You cannot change the behavior of the watchdog timer.

haploidus
Apr 7, 2009, 11:19 AM
Thanks for all the answers.