Ignore:
Timestamp:
Nov 10, 2001, 1:47:48 PM (24 years ago)
Author:
sandervl
Message:

Implemented Get/SetProcessAffinityMask & SetThreadAffinityMask

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/thread.cpp

    r6829 r7318  
    1 /* $Id: thread.cpp,v 1.32 2001-09-26 15:29:39 phaller Exp $ */
     1/* $Id: thread.cpp,v 1.33 2001-11-10 12:47:48 sandervl Exp $ */
    22
    33/*
     
    3131#include "exceptutil.h"
    3232#include "oslibmisc.h"
     33#include "oslibdos.h"
    3334#include <handlemanager.h>
    3435
     
    126127  O32_ExitThread(exitcode);
    127128}
     129/*****************************************************************************
     130 * Name      : DWORD SetThreadAffinityMask
     131 * Purpose   : The SetThreadAffinityMask function sets a processor affinity
     132 *             mask for a specified thread.
     133 *             A thread affinity mask is a bit vector in which each bit
     134 *             represents the processors that a thread is allowed to run on.
     135 *             A thread affinity mask must be a proper subset of the process
     136 *             affinity mask for the containing process of a thread. A thread
     137 *             is only allowed to run on the processors its process is allowed to run on.
     138 * Parameters: HANDLE hThread              handle to the thread of interest
     139 *             DWORD  dwThreadAffinityMask a thread affinity mask
     140 * Variables :
     141 * Result    : TRUE / FALSE
     142 * Remark    :
     143 * Status    : UNTESTED STUB
     144 *
     145 * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
     146 *****************************************************************************/
     147
     148DWORD WIN32API SetThreadAffinityMask(HANDLE hThread,
     149                                     DWORD  dwThreadAffinityMask)
     150{
     151  dprintf(("KERNEL32: SetThreadAffinityMask(%08xh,%08xh)",
     152           hThread, dwThreadAffinityMask));
     153
     154  if(hThread != GetCurrentThread()) {
     155      dprintf(("WARNING: Setting the affinity mask for another thread than the current one is not supported!!"));
     156      return FALSE;
     157  }
     158  return OSLibDosSetThreadAffinity(dwThreadAffinityMask);
     159}
    128160//******************************************************************************
    129161//******************************************************************************
     
    171203
    172204  SetWin32TIB();
     205
     206  DWORD dwProcessAffinityMask, dwSystemAffinityMask;
     207
     208  //Change the affinity mask of this thread to the mask for the whole process
     209  if(GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask) == TRUE) {
     210      SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
     211  }
     212
    173213  WinExe->tlsAttachThread();              //setup TLS structure of main exe
    174214  Win32DllBase::tlsAttachThreadToAllDlls(); //setup TLS structures of all dlls
Note: See TracChangeset for help on using the changeset viewer.