Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

haploidus

macrumors newbie
Original poster
Apr 6, 2009
6
0
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

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
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

macrumors newbie
Original poster
Apr 6, 2009
6
0
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

macrumors 68020
Nov 3, 2007
2,215
1,029
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.
 

haploidus

macrumors newbie
Original poster
Apr 6, 2009
6
0
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?
 

haploidus

macrumors newbie
Original poster
Apr 6, 2009
6
0
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

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
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

macrumors newbie
Original poster
Apr 6, 2009
6
0
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

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
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

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.