S
sfx1999
Guest
It works for me. Are you sure that it's not working?
When necessary, the ESP and EBP registers are stored on the stack. The rest can change (functions often return the values through registers).Aren't the registers stored when a function is called?
Generally EBP (the function’s local stack pointer) and ESP (the stack pointer) are stored at the start of a function, changed in some way, then restored at the end of the function, back to whatever they were originally.Aren't the registers stored when a function is called?
When necessary, the ESP and EBP registers are stored on the stack. The rest can change (functions often return the values through registers).Aren't the registers stored when a function is called?
deja vu?Generally EPB (the function’s local stack pointer) and ESP (the stack pointer) are stored at the start of a function, changed in some way, then restored at the end of the function, back to whatever they were originally.Aren't the registers stored when a function is called?
Meanwhile, other registers will be changing, and those changes last even after the function returns.
Especially functions that return values, in which case EAX will contain the return value (and possibly EDX).
If the CMP is used then conditional jump usually directly follows that opcode (not always, but since the instructions between those two CAN'T change EFlags, I don't see any problem). When using two threads, it's OS job not to mess up two thread's registers/flags.However, it will change the EFlags, and this will cause a problem.
Registers are not actually the problem.
The thread flags used for conditional jumps now become the problem.
If you don’t understand why, read up on how CMP works in conjunction with JE, JNZ, or whatever conditional jump you like.
Normally it wouldn’t be a problem.If the CMP is used then conditional jump usually directly follows that opcode (not always, but since the instructions between those two CAN'T change EFlags, I don't see any problem). When using two threads, it's OS job not to mess up two thread's registers/flags.
Now it makes senseThe risk I am trying to explain is that when he checks his flag while in the waiting loop (via CMP), that thread’s EFlags is going to change, and unfortunately that is the same thread that is executing the emitted code.
The purpose of using two threads together is so that you can do true execution of the emitted code with minimal overhead used to store copies of registers and flags.Using threads seams like a good idea, but won't jumping back and forth from thread to thread cause a performance hit?
Well that changes things a lot.I plan to interpret and compile at the same time, then just run from memory the next time