Jump to content

DosSetThreadAffinity: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Ak120 (talk | contribs)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
DosSetThreadAffinity allows the calling thread to change the processor affinity mask for the current thread.
DosSetThreadAffinity allows the calling thread to change the processor affinity mask for the current thread.  


==Syntax==
==Syntax==
<PRE>
  DosSetThreadAffinity (pAffinityMask)
  APIRET DosSetThreadAffinity


    (PMPAffinity pAffinityMask)
</PRE>
==Parameters==
==Parameters==
; pAffinityMask (PMPAffinity) input : Address of an MPAFFINITY structure that will become the current thread's affinity mask.  
;pAffinityMask (PMPAffinity) input:Address of an MPAFFINITY structure that will become the current thread's affinity mask.


==Return Code==
==Return Code==
ulrc APIRET) returns
;ulrc (APIRET) returns:DosSetThreadAffinity returns one of the following values
 
::13 ERROR_INVALID_DATA
DosSetThreadAffinity returns one of the following values
::87 ERROR_INVALID_PARAMETER


* 13        ERROR_INVALID_DATA
* 87        ERROR_INVALID_PARAMETER
==Remarks==
==Remarks==
The processor affinity mask contains 1 bit per processor. A maximum of 64 processors can be designated. If affinity bits are on for non-existent processors, the error ERROR_INVALID_DATA will be returned.  
The processor affinity mask contains 1 bit per processor. A maximum of 64 processors can be designated. If affinity bits are on for non-existent processors, the error ERROR_INVALID_DATA will be returned.


==Example Code==
==Example Code==
<PRE>
<PRE>
#define INCL_DOS#define INCL_32
#define INCL_DOS
#define INCL_32
#define INCL_DOSERRORS
#define INCL_DOSERRORS
#define INCL_NOPMAPI
#define INCL_NOPMAPI
#include os2.h>
#include <os2.h>
#include stdio.h>
#include <stdio.h>


int main(void)
int main(void){
{
  APIRET rc;
APIRET rc;
  MPAFFINITY affinity;
MPAFFINITY affinity;
 
  rc = DosSetThreadAffinity(affinity);
rc = DosSetThreadAffinity( affinity);
  printf("Set thread's affinity  rc = %08.8xh\n", rc);
printf("Set thread's affinity  rc = %08.8xh\n", rc);
  printf("Set thread's affinity  affinity[0] = %08.8xh, affinity[1] = %08.8xh\n",
printf("Set thread's affinity  affinity[0] = %08.8xh, affinity[1] = %08.8xh\n",
          affinity.mask[0], affinity.mask[1]);
        affinity.mask[0], affinity.mask[1]);
  return rc;
return rc;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosQueryThreadAffinity|DosQueryThreadAffinity]]
*[[DosQueryThreadAffinity]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 23:17, 8 December 2023

DosSetThreadAffinity allows the calling thread to change the processor affinity mask for the current thread.

Syntax

DosSetThreadAffinity (pAffinityMask)

Parameters

pAffinityMask (PMPAffinity) input
Address of an MPAFFINITY structure that will become the current thread's affinity mask.

Return Code

ulrc (APIRET) returns
DosSetThreadAffinity returns one of the following values
13 ERROR_INVALID_DATA
87 ERROR_INVALID_PARAMETER

Remarks

The processor affinity mask contains 1 bit per processor. A maximum of 64 processors can be designated. If affinity bits are on for non-existent processors, the error ERROR_INVALID_DATA will be returned.

Example Code

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

int main(void){
  APIRET rc;
  MPAFFINITY affinity;
 
  rc = DosSetThreadAffinity(affinity);
  printf("Set thread's affinity  rc = %08.8xh\n", rc);
  printf("Set thread's affinity  affinity[0] = %08.8xh, affinity[1] = %08.8xh\n",
          affinity.mask[0], affinity.mask[1]);
  return rc;
}

Related Functions