1 /***************************************************************************
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
5 ***************************************************************************/
14 #if defined(sparc) || defined(i686) || defined (x86_64)
17 pthread_mutex_t mutex_
;
25 int tryLock(int tries
=0, int waitmsecs
=0);
26 int getLock(int procSlot
, bool procAccount
=true);
27 int releaseLock(int procSlot
, bool procAccount
=true);
28 int tryShareLock(int tries
=0, int waitmsecs
=0,bool share
=false,bool upgrade
=false);
29 int getShareLock(int procSlot
, bool procAccount
=true);
30 int getExclusiveLock(int procSlot
, bool procAccount
=true,bool upgrade
=false);
31 int releaseShareLock(int procSlot
, bool procAccount
=true);
34 static int CASGen(volatile void *ptr
, InUse oldVal
, InUse newVal
);
35 static int CASL(volatile long *ptr
, long oldVal
, long newVal
);
36 static int CAS(volatile int *ptr
, int oldVal
, int newVal
);
37 int getLockVal(){ return lock
; }
39 printf("<MUTEX name=%s lock=%d pslot=%d> </MUTEX>\n", name
, lock
,pSlot
);