Unix to Windows Porting Dictionary for HPC

RSS

Links

Function List

pthread_equal


Table of Contents

Unix
Windows
Purpose
Discussion

Unix

header file: pthread.h

int pthread_equal(pthread_t t1, pthread_t t2);

Windows

header file: Windows.h

DWORD WINAPI GetCurrentThreadId(void);

DWORD WINAPI GetThreadId(
  __in  HANDLE Thread
);
      

Purpose

The pthread_equal function is used to compare the thread IDs of two threads. It will return a non-zero value if the two are equal and a zero value if they are not.

Discussion

In the Windows threading model a thread has a HANDLE which is the normal method by which the object is manipulated. In addition to its handle each thread in the system has a system-wide unique id which can be accessed with the GetThreadId and GetCurrentThreadID functions. While there is no direct single call to match the POSIX pthread_equal function, a simple numeric compare after making the two get thread id calls would achieve the same result.

blog comments powered by Disqus
Valid HTML 4.01 Transitional Valid CSS!