Re: [fpc-pascal] Any Way to catch endless loop in fpc in Wince?

2009-11-11 Thread epergola


I mean at runtime, where the app is deployed, not in the Lazarus IDE
debugger.

-- 
View this message in context: 
http://old.nabble.com/Any-Way-to-catch-endless-loop-in-fpc-in-Wince--tp26293620p26297681.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Any Way to catch endless loop in fpc in Wince?

2009-11-11 Thread Jonas Maebe


On 11 Nov 2009, at 00:55, epergola wrote:

Is there a way (or a 3rd party component or a library) to catch an  
endless

loop after x seconds
in applications running on arm Wince?


It is not possible to know whether a loop is endless or not (at least  
not in the general case, see the halting problem). If you simply  
want to know whether your application has run its main loop within the  
last x seconds, you can use a global variable and an extra thread:
* set the variable to 1 in the thread and sleep x seconds (note that  
you have to do this with interlockedexchange, otherwise you can get  
memory synchronisation issues)

* set it to 0 whenever you execute the main application loop (idem)
* if it's still 1 when the thread wakes up then the main application  
loop has not run for x seconds


If you have multiple threads in your program, you will need multiple  
global variables.



Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[2]: [fpc-pascal] Any Way to catch endless loop in fpc in Wince?

2009-11-11 Thread JoshyFun
Hello FPC-Pascal,

Wednesday, November 11, 2009, 10:34:09 AM, you wrote:

JM It is not possible to know whether a loop is endless or not (at least
JM not in the general case, see the halting problem). If you simply
JM want to know whether your application has run its main loop within the
JM last x seconds, you can use a global variable and an extra thread:
JM * set the variable to 1 in the thread and sleep x seconds (note that
JM you have to do this with interlockedexchange, otherwise you can get
JM memory synchronisation issues)
JM * set it to 0 whenever you execute the main application loop (idem)
JM * if it's still 1 when the thread wakes up then the main application
JM loop has not run for x seconds
JM If you have multiple threads in your program, you will need multiple
JM global variables.

Or maybe using the same system as Windows, post a custom message to
the application and the handler of that message notify the watchdog
thread with an acknowledge procedure. If acknowledge takes more than
X seconds them the hang in endless loop is quite sure. Or maybe
in the OnIdle event of the application ?

-- 
Best regards,
 JoshyFun

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Any Way to catch endless loop in fpc in Wince?

2009-11-10 Thread epergola

Hi
Is there a way (or a 3rd party component or a library) to catch an endless
loop after x seconds
in applications running on arm Wince?

-- 
View this message in context: 
http://old.nabble.com/Any-Way-to-catch-endless-loop-in-fpc-in-Wince--tp26293620p26293620.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal