Commit 6a695ced authored by simonmar's avatar simonmar
Browse files

[project @ 2005-05-24 15:43:32 by simonmar]

implement lockClosure properly
parent e022e6a0
...@@ -33,7 +33,7 @@ xchg(StgPtr p, StgWord w) ...@@ -33,7 +33,7 @@ xchg(StgPtr p, StgWord w)
StgWord result; StgWord result;
result = w; result = w;
__asm__ __volatile__ ( __asm__ __volatile__ (
"xchgl %1,%0" "xchg %1,%0"
:"+r" (result), "+m" (*p) :"+r" (result), "+m" (*p)
: /* no input-only operands */ : /* no input-only operands */
); );
...@@ -43,15 +43,26 @@ xchg(StgPtr p, StgWord w) ...@@ -43,15 +43,26 @@ xchg(StgPtr p, StgWord w)
INLINE_HEADER StgInfoTable * INLINE_HEADER StgInfoTable *
lockClosure(StgClosure *p) lockClosure(StgClosure *p)
{ {
#if i386_HOST_ARCH || x86_64_HOST_ARCH
StgWord info; StgWord info;
#if 0
do { do {
info = xchg((P_)&p->header.info, (W_)&stg_WHITEHOLE_info); info = xchg((P_)&p->header.info, (W_)&stg_WHITEHOLE_info);
if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info; if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info;
yieldThread(); yieldThread();
} while (1); } while (1);
#else #else
info = p->header.info; ACQUIRE_SM_LOCK
#endif
}
INLINE_HEADER void
unlockClosure(StgClosure *p, StgInfoTable *info)
{
#if i386_HOST_ARCH || x86_64_HOST_ARCH
// This is safe enough, because lockClosure() does the memory barrier:
p->header.info = info;
#else
RELEASE_SM_LOCK;
#endif #endif
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment