Re: windows threads work!!

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Mon, 10 Jul 2006 07:00:41 -0700, jacques desch=EAnes
<guest at RapidEuphoria.com> wrote:

>In the past I tested threads in euphoria without any success. At my
>first try and didn't insist because At that time i thought it was a
>limitation of euphoria interpreter.
It is. Btw, your example does not run on 2.4.
>But this morning reading "windows internals" I learned that windows
>create a new stack for each thread a process create. if so multithread
>should in euphoria!
>I decided to revisit it and IT WORKED!!
If you use Eu to create pure windows/c_func threads then all will be
fine. However Eu vars are not held on the windows stack, so using Eu
code will fail; eg in function IncCounter after while 1 do add:
if not equal(lower("AAA"),"aaa") then
    puts(1,"lower(AAA)!=aaa\n")
    if getc(0) then end if
    abort(0)
 end if

and after while spinlock < 2 do add:
if not equal(lower("BBB"),"bbb") then
    puts(1,"lower(BBB)!=bbb\n")
    if getc(0) then end if
    abort(0)
 end if

Also, replace Sleep(500) with c_proc(iSleep,{500}) to avoid an almost
inevitable type check on ms.
The resulting program will fail or crash at random.

TDLL in the archives shows how you can multi-OS-thread C/asm code from
Eu, but you cannot multi-OS-thread Eu code, not without doing
something like converting it to a dll first.

Regards,
Pete
PS It is also not as simple as two threads calling the same routine
(lower) simultaneously; the glitch in Sleep() shows it is re-using
internal temporaries or something; if you comment out the lower call
inside IncCounter, it works until the end, but the 'return 0' seems to
spanner the last lower call from the main pgm.

PPS Al: the example did not work for me at all on Eu 2.4 but did on Eu
2.5 (on win98), until as above I replaced Sleep() with c_func and then
2.4 nearly got to the end before crashing blink)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu