Possible to turn off watchdog timer on simulator?

Discussion in 'iOS Programming' started by haploidus, Apr 6, 2009.

  1. macrumors newbie

    Joined:
    Apr 6, 2009
    #1
    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
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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?
     
  3. thread starter macrumors newbie

    Joined:
    Apr 6, 2009
    #3
    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.
     
  4. macrumors 68000

    Joined:
    Nov 3, 2007
    #4
    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.
     
  5. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    Where are you doing this printing? And perhaps it is running so fast on the simulator, you are overflowing a buffer or something.
     
  6. thread starter macrumors newbie

    Joined:
    Apr 6, 2009
    #6
    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?
     
  7. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Yes, but how often is this printf getting called? And where in the code are you looping?
     
  8. thread starter macrumors newbie

    Joined:
    Apr 6, 2009
    #8
    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.
     
  9. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #9
    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.
     
  10. thread starter macrumors newbie

    Joined:
    Apr 6, 2009
    #10
    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
     
  11. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #11
    Right, because (according to this theory) it takes 20 seconds to fill the buffer, so stopping before then won't trigger the problem.
     
  12. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #12
    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.
     
  13. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #13
    The answer to your question is NO. You cannot change the behavior of the watchdog timer.
     
  14. thread starter macrumors newbie

    Joined:
    Apr 6, 2009

Share This Page