slowLockMutex / putHeavyLock

Maxim Kizub M.Kizub at post.skynet.lt
Mon Dec 18 01:15:47 PST 2000


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Edouard,

Sunday, December 17, 2000, 9:49:26 PM, you wrote:


EGP> Maxim Kizub wrote:

>> >>   I have sometimes assertion erros
>> >> from putHeavyLock method in
>> >>         assert(*lkp == LOCKINPROGRESS);
>> >>
>> >> So, the question is - how lkp is
>> >> supposed to be protected in current thread
>> >> from being modified from others threads?
>> >>
>>
>> GB> Which COMPARE_AND_EXCHANGE macro does it use?
>>
EGP> As it run under Windows, it should be _compareAndExchange from
EGP> config/i386/win32/win32-md.asm.  But _this_ is not SMP safe as
GCC
EGP> inlined version.

EGP> You should use `lock' prefix with `cmpxchg' instruction near
line 88 but
EGP> as I don't remember the correct syntax, I can't send you a diff.

EGP> Could you try that and send me the correct line ?

I just set as you proposed:

__declspec( naked )
int _compareAndExchange(void*, void*, void*) {
        __asm {
        mov ecx,dword ptr [esp+4]       ; addr
        mov eax,dword ptr [esp+8]       ; old
        mov edx,dword ptr [esp+12]      ; new
        lock cmpxchg dword ptr [ecx],edx
        je l7
        mov eax,0
        ret
l7:
        mov eax,1
        ret
        }
}

and error dissapeared.
Well, at least I was unable to reproduces it in debugger.
It failed once, but in the loop of 100 runs of kaffe,
and I'm not sure the reason was the assertion
(error message was not about assertion).

Som it looks like 'lock' prefix helps.
Do you have a really hard test of threads?

- --
Best regards,
 Maxim                            mailto:M.Kizub at post.skynet.lt

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5i

iQA/AwUBOj3Hw+w5enpENJF+EQK9/QCfWh8AtMVwrD8fLTzWhB7/8TQxjLoAniXX
4WgigDFNV/A6zU+1enG6C+S3
=A6PJ
-----END PGP SIGNATURE-----




More information about the kaffe mailing list