NT32Pkg: Bind NT32 process to a single core to avoid NT32 crash issue in some multi-core processors.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Ni Ruiyu <ni.ruiyu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16951 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Qiu Shumin 2015-02-28 02:36:06 +00:00 committed by shenshushi
parent 83685b4391
commit 16b6347b30
1 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,6 @@
/**@file /**@file
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -183,6 +183,10 @@ Returns:
CHAR16 *MemorySizeStr; CHAR16 *MemorySizeStr;
CHAR16 *FirmwareVolumesStr; CHAR16 *FirmwareVolumesStr;
UINTN *StackPointer; UINTN *StackPointer;
UINT32 ProcessAffinityMask;
UINT32 SystemAffinityMask;
INT32 LowBit;
// //
// Enable the privilege so that RTC driver can successfully run SetTime() // Enable the privilege so that RTC driver can successfully run SetTime()
@ -199,6 +203,20 @@ Returns:
SecPrint ("\nEDK II SEC Main NT Emulation Environment from www.TianoCore.org\n"); SecPrint ("\nEDK II SEC Main NT Emulation Environment from www.TianoCore.org\n");
//
// Determine the first thread available to this process.
//
if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask, &SystemAffinityMask)) {
LowBit = (INT32)LowBitSet32 (ProcessAffinityMask);
if (LowBit != -1) {
//
// Force the system to bind the process to a single thread to work
// around odd semaphore type crashes.
//
SetProcessAffinityMask (GetCurrentProcess (), (INTN)(BIT0 << LowBit));
}
}
// //
// Make some Windows calls to Set the process to the highest priority in the // Make some Windows calls to Set the process to the highest priority in the
// idle class. We need this to have good performance. // idle class. We need this to have good performance.