From: VMware, Inc <> Date: Thu, 17 Jun 2010 21:37:51 +0000 (-0700) Subject: lib/thread and lib/lock: cleanup the cooperation X-Git-Tag: 2010.06.16-268169~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa54712d0486521fe15e3894a2cf07b2f9cde3ba;p=thirdparty%2Fopen-vm-tools.git lib/thread and lib/lock: cleanup the cooperation The watchdog routine needs to be used by both MX and MXUser however planting the callback in only done in userland - move ownership of the callback (and planting it) to MXUser. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/include/userlock.h b/open-vm-tools/lib/include/userlock.h index 04901c824..cd6571781 100644 --- a/open-vm-tools/lib/include/userlock.h +++ b/open-vm-tools/lib/include/userlock.h @@ -149,6 +149,8 @@ void MXUser_DestroyCondVar(MXUserCondVar *condVar); struct MX_MutexRec; +void MXUser_PlantThreadWatchDog(void (*func)(void)); + #if defined(VMX86_VMX) MXUserRecLock *MXUser_InitFromMXRec(const char *name, struct MX_MutexRec *mutex, diff --git a/open-vm-tools/lib/lock/ul.c b/open-vm-tools/lib/lock/ul.c index e7cece736..d4a57f360 100644 --- a/open-vm-tools/lib/lock/ul.c +++ b/open-vm-tools/lib/lock/ul.c @@ -21,12 +21,13 @@ #include "util.h" #include "userlock.h" #include "ulInt.h" -#include "ulIntShared.h" #include "hashTable.h" static Bool mxInPanic = FALSE; // track when involved in a panic +void (*MXUserVThreadWatchDog)(void); + Bool (*MXUserTryAcquireForceFail)() = NULL; static MX_Rank (*MXUserMxCheckRank)(void) = NULL; @@ -643,3 +644,28 @@ MXUserListLocks(void) } #endif } + + +/* + *----------------------------------------------------------------------------- + * + * MXUser_PlantThreadWatchDog -- + * + * Plant the pointer to VThread_WatchDog. + * + * If this is called lib/thread is around. + * + * Results: + * None + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +void +MXUser_PlantThreadWatchDog(void (*func)(void)) +{ + MXUserVThreadWatchDog = func; +} diff --git a/open-vm-tools/lib/lock/ulInt.h b/open-vm-tools/lib/lock/ulInt.h index bba7d9a77..37ca5f2cd 100644 --- a/open-vm-tools/lib/lock/ulInt.h +++ b/open-vm-tools/lib/lock/ulInt.h @@ -39,6 +39,7 @@ typedef pthread_t MXThreadID; #include "vm_basic_types.h" #include "vthreadBase.h" #include "hostinfo.h" +#include "ulIntShared.h" #if defined(MXUSER_STATS) #include "circList.h" diff --git a/open-vm-tools/lib/lock/ulIntShared.h b/open-vm-tools/lib/lock/ulIntShared.h index 9e2d439c4..1feae6a54 100644 --- a/open-vm-tools/lib/lock/ulIntShared.h +++ b/open-vm-tools/lib/lock/ulIntShared.h @@ -19,8 +19,12 @@ #ifndef _ULINTSHARED_H_ #define _ULINTSHARED_H_ +extern void (*MXUserVThreadWatchDog)(void); + extern void MXUserListLocks(void); +extern void MXUserPerThreadData(VThreadID, uint64 *, uint64 *); + extern void MXUserInstallMxHooks(void (*theLockListFunc)(void), MX_Rank (*theRankFunc)(void), void (*theLockFunc)(struct MX_MutexRec *lock),