This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Infinite loops

Hi, How can we overcome infinite loops in C programming using keil compiler............ can anyone plz answer my question.... Actually i want to know
1)what are the adverse effects a program leads to when it contains a infinite loops in it.

2)how can u find them out means how u debug your program which contains infinite loops using keil debugger .

3)Does the keil compiler is useful to find such type of bugs(infinite loops) in a program are we have to rely on third party debugging tools.

4)How to overcome such bugs(infinite loops) in the program.

5)what are the neccessary measures to be taken to prevent infinite loops in a C program.....

thanks in advance............ bharath

  • The amount of questions kind of suggests that you are looking for answers to a school assignmnet.

    Anyway - there are no 100% proof methods to view C/C++ code and detect possible infinite loops. At least not in reasonably complex real-world code.

    If you get stuck in an infinite loop, it is trivial to find out where. Just break the execution and look where you are... Figuring out a good way to avoid the problem, or the interaction that caused it, can be a lot harder.

    So, be careful. Think before writing code. Think about timeouts and watchdog usage.

  • Funny in "Keil 8051 C Compiler" you need at least one infinite loop or it will not work.

    Sorry, but that will not help your homework.

  • "Funny in 'Keil 8051 C Compiler' you need at least one infinite loop or it will not work."

    Not necessarily: instead of an infinite loop, you could have a dead-end in the form of a power-down state that can only be exited by a reset...

  • Your homework seems to be missing a preliminary question:

    "Are All Infinite loops bad?"

    Especially in embedded systems, there's a number of cases where an infinite loop is just what you do want!

  • I always rely on third party tools to find the infinite loops in my code. In particular, TuringSoft makes a great plug-in for lint that detects any program that runs forever, and prints a warning. I'd add a link, but it's too long to fit into the margin of this post.