flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Threads

Author
Thread Post new topic Reply to topic
Posetf



Joined: 01 Mar 2004
Posts: 35
Location: London
Posetf
Hi,
I am writing an interpreter/compiler, and what I think I really want to do is:
low_mem:
<IL> -- code
<GVAR> -- shared data
<TVAR> -- thread-specific data
high_mem:
My (insane) plan is to allocate memory for TVAR at CreateThread, and on
thread switch I want to "rep xchg" (wishful thinking, but ykwim) the TVAR
block.

One thing I should perhaps mention is that I want <IL> to contain absolute
memory addresses of both GVAR and TVAR, and mostly treat them identically.

Is there any way to intercept the thread switch and do a little bit of
housekeeping? I would be sooo happy if I could!

Regards,
Pete
PS I am a complete thread noob, just trying to plan ahead
Post 13 Jan 2006, 00:51
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
What OS? There are already facilities inside Windows for thread-specific data called TLS (Thread Local Storage)
Post 13 Jan 2006, 03:13
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Posetf



Joined: 01 Mar 2004
Posts: 35
Location: London
Posetf
comrade wrote:
What OS? There are already facilities inside Windows for thread-specific data called TLS (Thread Local Storage)


Windows(9Cool. I cannot think of a way to use TLS, I need something at the point of the context switch. What I think I want to do is insert a bit of code after the OS has saved the current context and before or just after it restores the new one...

The only other way round it is to copy the <IL> at CreateThread() time, and patch all the references to (the new) <TVAR>, which might not be as bad as it sounds.
Post 13 Jan 2006, 15:52
View user's profile Send private message Visit poster's website 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 GitHub, YouTube, Twitter.

Website powered by rwasa.