News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

speed problems

Started by ecube, September 14, 2007, 05:52:27 PM

Previous topic - Next topic

ecube

i've ran into lot of problems where code execute *too fast and the results were not what i wanted. Only solution i've found was using invoke Sleep alot but I was wondering if anyone has had this problem and knows a better solution? I actually don't understand how this happens because if you

invoke func
then continue on with code

should invoke func fully finish before it returns? because I find myself these days having to put Sleep way to much just to slow things down :\

Mark Jones

Hi, are you testing this on a multi-core CPU? Perhaps the call is spawning a second thread which doesn't block code execution, so the call appears to "fall through?"

Perhaps another option is changing your code to manually spawn worker thread(s) for these or all functions, and design the main code to wait for worker thread responses.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hutch--

cube,

It really depends what you are trying to do with the code in terms of using SleepEx(). It is handy if you are doing a simple timing where you are waiting on a result but if you are going to time multiple threads you will be safer by using the operating system to synchronise the threads. SleepEx() is simply one of the "Wait" functions and while some of them are a bit clunky things like using a critical section makes sense in many contexts.

Just vbe careful that if you use some of thse mechanisms without fully understanding them you can at times end up with laggy code that does not need to be that way. If your use of the SleepEx() function does the job, don't be afraid to use it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php