From EDM2
Revision as of 02:42, 26 October 2017 by Ak120 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

DosQueryThreadAffinity allows a thread to inquire for the current thread's processor affinity mask and the system's capable processor affinity mask.


APIRET DosQueryThreadAffinity (ULONG scope, PMPAffinity pAffinityMask)


scope(ULONG) input
AFNTY_THREAD Return the current threads processor affinity mask.
AFNTY_SYSTEM Return the system's current capable processor affinity mask.
pAffinityMask(PMPAffinity) input 
Address of MPAffinity structure to receive the affinity mask. Processors 0 31 are in mask [0] and processors 32 63 are in mask [1].

Return Code

ulrc APIRET) returns

DosQueryThreadAffinity returns one of the following values



DosQueryThreadAffinity allows a thread to ask the Processor Affinity Mask for

  • The current thread's processor affinity mask, scope =AFNTY_THREAD, returns qwThreadAffinity, for the calling thread.
  • The system's capable processor affinity mask, scope=AFNTY_SYSTEM, returns qwCapableAffinity for the system. The caller may then use any subset of the returned affinity mask to change the threads processor affinity in a later call to DosSetThreadAffinity.

Example Code

#define INCL_DOS
#define INCL_32
#include <os2.h>
#include <stdio.h>

int main(void){
  APIRET rc;
  MPAFFINITY affinity;

  rc = DosQueryThreadAffinity(AFNTY_SYSTEM, affinity);
  printf("Query system's affinity  rc = %08.8xh\n",rc);
  printf("Query system's affinity  affinity[0] = %08.8xh, affinity[1] = %08.8xh\n",
          affinity.mask[0], affinity.mask[1]);
  return rc;

Related Functions