flat assembler
Message board for the users of flat assembler.

Index > Windows > Thread

Author
Thread Post new topic Reply to topic
eskizo



Joined: 22 Nov 2005
Posts: 59
eskizo
Hi,

What would happen if I create 2 simutaneous threads (CreateThread), both accessing the registers at the same time, like:

...
Code:
thread1:
xor eax, eax
mov ebx, 10
ret
...

thread2:
or eax, ebx
add eax, 1
ret
...
    


Does each thread has their "own" registers? or the registers are for all threads at the same time... ?

thankyou!
Post 15 Jun 2009, 18:07
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

Does each thread has their "own" registers? or the registers are for all threads at the same time... ?

Every thread has its own registers. thread1 will invariably return EAX==0 and EBX==10, and thread2 will return EAX = (EAX | EBX) + 1, where the previous state of both registers won't be inherited from thread1 never.
Post 15 Jun 2009, 18:13
View user's profile Send private message Reply with quote
eskizo



Joined: 22 Nov 2005
Posts: 59
eskizo
OK, thankyou very much!
Post 15 Jun 2009, 20:17
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
When Windows switches between threads it saves their registers, otherwise it would have been total chaos lol!
Post 16 Jun 2009, 02:07
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.