flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Furs 18 Jun 2022, 14:14
I only know the pause instruction that hints the CPU it's in a spinlock. Use it in the loop.
Also when you read the memory in a spinlock, do it without lock prefix. Do a normal read so you don't congest the bus. Once your read is satisfied correctly, then do the whole locked thing and verify again. You can't trust the results from the normal read, it's there just to avoid locking all the time. |
|||
![]() |
|
sylware 18 Jun 2022, 15:20
yep, I found it in AMD documentation using the right keywords.
It is exactly that. That said, when in the loops would you use the pause instruction? spinlock linux code (linus tree) is the product of "not very sane" (to stay polite) minds (something is clearly wrong with them, wonder how they could commit anything to the linux tree). |
|||
![]() |
|
Ali.Z 18 Jun 2022, 20:01
Intel wrote:
_________________ Asm For Wise Humans |
|||
![]() |
|
Furs 19 Jun 2022, 14:48
Yep like Ali.Z posted, though you'll probably find using lock cmpxchg a lot more often since it's much more flexible. Depending on what kind of locking mechanism you need. Note that normal xchg has implicit lock prefix on memory operand, so the above does in fact that a lock on the bus.
BTW it should be [lockvar] since you're addressing the memory, not its address. |
|||
![]() |
|
sylware 19 Jun 2022, 15:33
yeah, I think I am going to use lock cmpxchg.
|
|||
![]() |
|
Ali.Z 19 Jun 2022, 18:23
Furs wrote: BTW it should be [lockvar] since you're addressing the memory, not its address. Yes I know, but this is a copy-paste from Intel (C inline assembly example); I did not write it. _________________ Asm For Wise Humans |
|||
![]() |
|
sylware 20 Jun 2022, 13:47
I thank you all for you help.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.