News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Lock/Unlock

Started by xanatose, July 09, 2012, 05:05:11 PM

Previous topic - Next topic

xanatose

What assembly instructions are available for creating a lightweight mutex on the same process.

I can use CriticalSection on Win32. But I was wondering if there where assembly instructions that where to accomplish the same thing as a CriticalSection but without the need of calling the API.

Also, How does one implement something similar to the InterlockedIncrement, InterlockedAcquire, etc?

qWord

hi,
Quote from: xanatose on July 09, 2012, 05:05:11 PM
What assembly instructions are available for creating a lightweight mutex on the same process.

I can use CriticalSection on Win32. But I was wondering if there where assembly instructions that where to accomplish the same thing as a CriticalSection but without the need of calling the API.
The problem is that you need to wait for the ownership. Using the PAUSE instruction in a wait loop may be a solution.

Quote from: xanatose on July 09, 2012, 05:05:11 PM
Also, How does one implement something similar to the InterlockedIncrement, InterlockedAcquire, etc?
The Interlock* functions are implemented using the LOCK-Instruction prefix (see documentation). Also note, that not all functions are available for x86-32/64.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

LOCK works - bus lock
certain instructions imply bus lock
i sometimes use XCHG EAX,mem32 for that reason
you can change and read a semaphore at the same time