flat assembler
Message board for the users of flat assembler.

flat assembler > Heap > Question about thread safety

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 170
Location: Russian Federation, Sochi
Hello Tomasz.
Previously I read that fasmdll isn`t thread safety, but fasmg could be. (How unused by other logic register helps program to be thread safety?)

Can you explain on simplest dll (in 2 variants with thread safety and without) how thread safety works: what happend with or without it? I understand that without thread safety program works incorrect in case of multythreads, but how exactly both variants looks like? And how such things maked in fasm?

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 10 Jul 2018, 13:24
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6928
Location: Kraków, Poland
What hurts thread safety is the use of global variables. If you tried to call fasm in multiple threads to assemble many sources in parallel, all the threads would try to use the same global variables and would destructively interfere with each other.

It is possible to make fasm.dll safe with CreateMutex, in fact I do not know why I did not do that. This would ensure that every time fasm_Assemble was called in another thread it would have to wait until the first thread finishes its job. Of course this would also mean that assembling multiple files in parallel would still be impossible.

In case of fasmg it is possible to put "variables.inc" in a "local" block (or simply "virtual at ebp-size") and have it use local variables of an instance of outer procedure, because EBP is never used anywhere in the fasmg engine so addressing every variable through EBP is safe. Therefore running multiple assemblies in parallel would be possible in this case.
Post 10 Jul 2018, 13:51
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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.