]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/lock: bound thread ID creation on Windows
authorVMware, Inc <>
Mon, 26 Sep 2011 18:36:32 +0000 (11:36 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 26 Sep 2011 18:36:32 +0000 (11:36 -0700)
Apparently thread IDs are reclaimed immediately on POSIXen. On Windows
thread IDs are essentially unique leading to huge amounts of
MXUser (lock) tracking memory being wasted.

The fix is simple - use VThread_CurID. This is our bounded, quickly
recycled thread ID service.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/lock/ulInt.h

index d5b793e2ba342b2c02d224680ccfc982fed3d2fc..d6a52b6bf64a7597a20b9ee093af4f6c3d9de28f 100644 (file)
@@ -380,13 +380,18 @@ MXUserGetThreadID(void)
 {
    /* All thread types must fit into a uintptr_t  */
 
+   ASSERT_ON_COMPILE(sizeof(VThreadID) <= sizeof (void *));
+   return (void *) (uintptr_t) VThread_CurID();
+
+/*
 #if defined(_WIN32)
-   ASSERT_ON_COMPILE(sizeof(DWORD) <= sizeof (void *));
-   return (void *) (uintptr_t) GetCurrentThreadId();
+   ASSERT_ON_COMPILE(sizeof(VThreadID) <= sizeof (void *));
+   return (void *) (uintptr_t) VThread_CurID();
 #else
    ASSERT_ON_COMPILE(sizeof(pthread_t) <= sizeof (void *));
    return (void *) (uintptr_t) pthread_self();
 #endif
+*/
 }