I was just wondering...when u create a new thread does it create it's own space for variables within the program creating the thread? in other words it uses its own addresses for them? and adds it's own ebp value?

second question is how would i pass a structure by val into threadproc before the structure changes in the main prog?

third question the proc macro eg

proc SumThing,Variables
temp dd 0
enter
push wateva
;code
pop wateva
return

I'd like to know wat happens behind the scenes here not the push/pop the enter and retrn and otherstuff?

Some help would be appreciated :)
thnx
Posted on 2003-01-17 04:43:39 by keyoke
Threads run in the same address space as the program that created them.
Threads have their own stack.

So they can acces your global programm variables/structures/matrix like from any other part of your application.

However becuse they run independently you should protect against concurent access to the same variable
via a CriticalSection or other syncronization objects like Mutx or Semaphores.

Theoretically you could assume that access to a single dword variable done like this
move ,eax
will not get interuppted by the other thread but if you want to fill in a longer structure you could get interupted by the other thread while you are at the half way and the other thread will read half the new values and half the old values....

A word of caution:
Such multithread related errors are hard to find as they depend on time relations betwen threads, CPU, machine load etc... so they might never appear on your test machine while always appear on another different machine.... take care and use multithreading ONLY when benefits more than it generates problems
Posted on 2003-01-17 09:35:32 by BogdanOntanu
ok thnx i think that helps alot :)
Posted on 2003-01-18 05:17:27 by keyoke