Category : Files from Magazines
Archive   : OCT91.ZIP
Filename : 2N10016A

 
Output of file : 2N10016A contained in archive : OCT91.ZIP
;*** AllocateSpinLock - Allocate Spin (short term) Lock Object.
;
; This macro is used to allocate a spin lock and store its
; handle in a specified location. In the actual implementation,
; this macro doesn't even call a package, but resets a spinlock
; to a known state. The place where we store the handle IS the
; spinlock.
;
; Usage: AllocateSpinLock lock

AllocateSpinLock MACRO lck
mov lck, 0 ; initialize the lock.
ENDM

;*** DeallocateSpinLock - Deallocate Spin (short term) Lock Object.
;
; This macro is used to deallocate a spin lock and return
; it to the system. In this implementation, since the user's
; handle storage actually serves as the lock itself, we don't
; do anything here at all. If we change the implementation, then
; the source can just be recompiled and the DeallocateSpinLock
; calls will do something meaningful, like deallocating pool.
;
; Usage: DeallocateSpinLock lock

DeallocateSpinLock MACRO lck
mov lck, 0 ; reset the lock.
ENDM

;*** AcquireSpinLock - Acquire Spin (short term) Lock.
;
; This macro is used to acquire a spin lock in a multiprocessor
; system so that access to a mutually-exclusive object can be
; controlled in an MP-safe way. To setup a spinlock, initialize
; it with the AllocateSpinLock macro. Then to acquire the lock,
; use this macro. To free up the lock when you're done, use the
; ReleaseSpinLock macro.
;
; Usage: AcquireSpinLock lock [, scratch-reg]

AcquireSpinLock MACRO lck, scr
IF MULTIPROCESSOR
IFIDN ,<>
push ax
mov ax, 1
@@: xchg lck, ax
or ax, ax
jnz @b
pop ax
ELSE
mov scr, 1
@@: xchg lck, scr
or scr, scr
jnz @b
ENDIF
ENDIF
ENDM

;*** ReleaseSpinLock - Release Spin (short term) Lock.
;
; This macro is used to release a spin lock in a multiprocessor
; system so that access to a mutually-exclusive object can be
; controlled in an MP-safe way. To setup a spinlock, initialize
; it with the AllocateSpinLock macro. To acquire the lock, use
; AcquireSpinLock. To free up the lock when you're done, use
; the ReleaseSpinLock macro.
;
; Usage: ReleaseSpinLock lock

ReleaseSpinLock MACRO lck
IF MULTIPROCESSOR
mov lck, 0
ENDIF
ENDM

Figure 1. Multiprocessor-Safe Spinlock Macros for 80x86 Assembly Language.


  3 Responses to “Category : Files from Magazines
Archive   : OCT91.ZIP
Filename : 2N10016A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/