- Timestamp:
- Nov 10, 2001, 1:47:48 PM (24 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/initkernel32.cpp
r6646 r7318 1 /* $Id: initkernel32.cpp,v 1. 7 2001-09-05 12:57:58 birdExp $1 /* $Id: initkernel32.cpp,v 1.8 2001-11-10 12:47:46 sandervl Exp $ 2 2 * 3 3 * KERNEL32 DLL entry point … … 39 39 #include "initterm.h" 40 40 #include <win32type.h> 41 #include <win32api.h> 41 42 #include <odinlx.h> 42 43 #include "oslibmisc.h" … … 179 180 //keys that affect windows version) 180 181 InitDynamicRegistry(); 182 183 //Set the process affinity mask to the system affinity mask 184 DWORD dwProcessAffinityMask, dwSystemAffinityMask; 185 GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask); 186 SetProcessAffinityMask(GetCurrentProcess(), dwSystemAffinityMask); 181 187 break; 182 188 } -
trunk/src/kernel32/oslibdos.cpp
r7286 r7318 1 /* $Id: oslibdos.cpp,v 1.8 3 2001-11-05 15:00:36 sandervl Exp $ */1 /* $Id: oslibdos.cpp,v 1.84 2001-11-10 12:47:46 sandervl Exp $ */ 2 2 /* 3 3 * Wrappers for OS/2 Dos* API … … 2815 2815 //****************************************************************************** 2816 2816 //****************************************************************************** 2817 BOOL OSLibDosSetThreadAffinity(DWORD dwThreadAffinityMask) 2818 { 2819 static PROC_DosSetThreadAffinity pfnDosSetThreadAffinity = NULL; 2820 static BOOL fInit = FALSE; 2821 MPAFFINITY mask; 2822 2823 if(fInit == FALSE && pfnDosSetThreadAffinity == NULL) { 2824 HMODULE hDoscalls; 2825 if(DosQueryModuleHandle("DOSCALLS", &hDoscalls) == NO_ERROR) { 2826 DosQueryProcAddr(hDoscalls, 564, NULL, (PFN *)&pfnDosSetThreadAffinity); 2827 } 2828 fInit = TRUE; 2829 } 2830 if(fInit && pfnDosSetThreadAffinity == NULL) { 2831 SetLastError(ERROR_SUCCESS_W); 2832 return TRUE; 2833 } 2834 APIRET rc; 2835 USHORT sel = RestoreOS2FS(); 2836 2837 mask.mask[0] = dwThreadAffinityMask; 2838 mask.mask[1] = 0; //TODO: this might not be a good idea, but then again, not many people have > 32 cpus 2839 2840 rc = pfnDosSetThreadAffinity(&mask); 2841 SetFS(sel); 2842 2843 SetLastError(error2WinError(rc,ERROR_INVALID_PARAMETER)); 2844 return (rc == NO_ERROR); 2845 } 2846 //****************************************************************************** 2847 //****************************************************************************** 2848 BOOL OSLibDosQueryAffinity(DWORD fMaskType, DWORD *pdwThreadAffinityMask) 2849 { 2850 static PROC_DosQueryThreadAffinity pfnDosQueryThreadAffinity = NULL; 2851 static BOOL fInit = FALSE; 2852 MPAFFINITY mask; 2853 2854 if(fInit == FALSE && pfnDosQueryThreadAffinity == NULL) { 2855 HMODULE hDoscalls; 2856 if(DosQueryModuleHandle("DOSCALLS", &hDoscalls) == NO_ERROR) { 2857 DosQueryProcAddr(hDoscalls, 563, NULL, (PFN *)&pfnDosQueryThreadAffinity); 2858 } 2859 fInit = TRUE; 2860 } 2861 if(fInit && pfnDosQueryThreadAffinity == NULL) { 2862 *pdwThreadAffinityMask = 1; 2863 SetLastError(ERROR_SUCCESS_W); 2864 return TRUE; 2865 } 2866 2867 ULONG scope = (fMaskType == MASK_SYSTEM) ? AFNTY_SYSTEM : AFNTY_THREAD; 2868 2869 APIRET rc; 2870 USHORT sel = RestoreOS2FS(); 2871 2872 rc = pfnDosQueryThreadAffinity(scope, &mask); 2873 SetFS(sel); 2874 2875 if(rc == NO_ERROR) { 2876 *pdwThreadAffinityMask = mask.mask[0]; 2877 } 2878 SetLastError(error2WinError(rc,ERROR_INVALID_PARAMETER)); 2879 return (rc == NO_ERROR); 2880 } 2881 //****************************************************************************** 2882 //****************************************************************************** -
trunk/src/kernel32/oslibdos.h
r7275 r7318 1 /* $Id: oslibdos.h,v 1.3 7 2001-10-30 18:46:46sandervl Exp $ */1 /* $Id: oslibdos.h,v 1.38 2001-11-10 12:47:47 sandervl Exp $ */ 2 2 3 3 /* … … 320 320 PEAOP2 peaop2); 321 321 322 #endif 322 323 typedef struct _MPAFFINITY { /* afnty */ 324 ULONG mask[2]; /* CPUs 0 thru 31 in [0], CPUs 32 thru 63 in [1] */ 325 } MPAFFINITY; 326 typedef MPAFFINITY *PMPAFFINITY; 327 328 typedef APIRET (* APIENTRY PROC_DosQueryThreadAffinity)(ULONG scope, 329 PMPAFFINITY pAffinity); 330 331 /* scope values for QueryThreadAffinity */ 332 333 #define AFNTY_THREAD 0 334 #define AFNTY_SYSTEM 1 335 336 typedef APIRET (* APIENTRY PROC_DosSetThreadAffinity)(PMPAFFINITY pAffinity); 323 337 324 338 #endif … … 333 347 BOOL OSLibDosBeep(DWORD ulFreq, DWORD ulDuration); 334 348 ULONG OSLibDosGetProcAddress(HMODULE hModule, LPCSTR lpszProc); 349 350 BOOL OSLibDosSetThreadAffinity(DWORD dwThreadAffinityMask); 351 352 #define MASK_SYSTEM 0 353 #define MASK_THREAD 1 354 BOOL OSLibDosQueryAffinity(DWORD fMaskType, DWORD *pdwThreadAffinityMask); 355 356 #endif //__OSLIBDOS_H__ 357 -
trunk/src/kernel32/process.cpp
r4658 r7318 1 /* $Id: process.cpp,v 1. 8 2000-11-21 11:35:09sandervl Exp $ */1 /* $Id: process.cpp,v 1.9 2001-11-10 12:47:47 sandervl Exp $ */ 2 2 3 3 /* … … 125 125 { 126 126 ProcessAffinityMask = affmask; 127 //TODO: should update all threads, but that doesn't seem possible in OS/2 128 SetThreadAffinityMask(GetCurrentThread(), ProcessAffinityMask); 127 129 return TRUE; 128 130 } … … 137 139 if(lpProcessAffinityMask) 138 140 *lpProcessAffinityMask=ProcessAffinityMask; 139 if(lpSystemAffinityMask) 140 *lpSystemAffinityMask=1; 141 142 if(lpSystemAffinityMask) { 143 OSLibDosQueryAffinity(MASK_SYSTEM, lpSystemAffinityMask); 144 } 141 145 return TRUE; 142 146 } -
trunk/src/kernel32/stubs.cpp
r6646 r7318 1 /* $Id: stubs.cpp,v 1.3 2 2001-09-05 12:58:00 birdExp $1 /* $Id: stubs.cpp,v 1.33 2001-11-10 12:47:47 sandervl Exp $ 2 2 * 3 3 * Win32 KERNEL32 Subsystem for OS/2 … … 1789 1789 1790 1790 1791 /*****************************************************************************1792 * Name : DWORD SetThreadAffinityMask1793 * Purpose : The SetThreadAffinityMask function sets a processor affinity1794 * mask for a specified thread.1795 * A thread affinity mask is a bit vector in which each bit1796 * represents the processors that a thread is allowed to run on.1797 * A thread affinity mask must be a proper subset of the process1798 * affinity mask for the containing process of a thread. A thread1799 * is only allowed to run on the processors its process is allowed to run on.1800 * Parameters: HANDLE hThread handle to the thread of interest1801 * DWORD dwThreadAffinityMask a thread affinity mask1802 * Variables :1803 * Result : TRUE / FALSE1804 * Remark :1805 * Status : UNTESTED STUB1806 *1807 * Author : Patrick Haller [Mon, 1998/06/15 08:00]1808 *****************************************************************************/1809 1810 DWORD WIN32API SetThreadAffinityMask(HANDLE hThread,1811 DWORD dwThreadAffinityMask)1812 {1813 dprintf(("KERNEL32: SetThreadAffinityMask(%08xh,%08xh) not implemented.\n",1814 hThread,1815 dwThreadAffinityMask));1816 1817 return (0);1818 }1819 1820 1791 1821 1792 -
trunk/src/kernel32/thread.cpp
r6829 r7318 1 /* $Id: thread.cpp,v 1.3 2 2001-09-26 15:29:39 phallerExp $ */1 /* $Id: thread.cpp,v 1.33 2001-11-10 12:47:48 sandervl Exp $ */ 2 2 3 3 /* … … 31 31 #include "exceptutil.h" 32 32 #include "oslibmisc.h" 33 #include "oslibdos.h" 33 34 #include <handlemanager.h> 34 35 … … 126 127 O32_ExitThread(exitcode); 127 128 } 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 148 DWORD 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 } 128 160 //****************************************************************************** 129 161 //****************************************************************************** … … 171 203 172 204 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 173 213 WinExe->tlsAttachThread(); //setup TLS structure of main exe 174 214 Win32DllBase::tlsAttachThreadToAllDlls(); //setup TLS structures of all dlls
Note:
See TracChangeset
for help on using the changeset viewer.