Implementing a timer using threads

Dennis Kempin dennis at xardias.net
Mon Jan 29 09:40:50 PST 2007


Heinz wrote: 
> You could insert a block of asm code. Look here
> http://www.digitalmars.com/d/iasm.html for valid opcodes. Here
> http://www.acm.uiuc.edu/sigmil/talks/shellcode/sleep.asm is an approach.
> 
> This method is platform independant but not architecture independant,
> anyway, most computers processors are x86.
> 
> Good luck.

Hi Heinz,

thanks for your reply. I tried the following solution:
int timerFunction()
{
        while(true)
        {
                writefln("a");
                asm
                {
                        xor EAX,EAX;
                        mov EBX,0x77e61bea;
                        mov AX,1000;
                        push EAX;
                        call EBX;
                }

        }
        return 0;
}
but the result is a crash without any error message or warning. As the
comment of the asm code says "windows shellcode" i think it simply uses the
windows internel Sleep method. Still no way to make the thread go sleep in
linux.
Maybe I just should use linux/windows c API methods and insert a platform
fork. I will report here if i got a working solution.. Maybe I am not the
only one who needs timing. 

regards
Dennis


More information about the Digitalmars-d-learn mailing list