Revision: 16951
          http://sourceforge.net/p/edk2/code/16951
Author:   shenshushi
Date:     2015-02-28 02:36:06 +0000 (Sat, 28 Feb 2015)
Log Message:
-----------
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....@intel.com>
Reviewed-by: Ni Ruiyu <ni.ru...@intel.com>

Modified Paths:
--------------
    trunk/edk2/Nt32Pkg/Sec/SecMain.c

Modified: trunk/edk2/Nt32Pkg/Sec/SecMain.c
===================================================================
--- trunk/edk2/Nt32Pkg/Sec/SecMain.c    2015-02-27 17:54:29 UTC (rev 16950)
+++ trunk/edk2/Nt32Pkg/Sec/SecMain.c    2015-02-28 02:36:06 UTC (rev 16951)
@@ -1,6 +1,6 @@
 /**@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
 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
@@ -183,7 +183,11 @@
   CHAR16                *MemorySizeStr;
   CHAR16                *FirmwareVolumesStr;
   UINTN                 *StackPointer;
+  UINT32                ProcessAffinityMask;
+  UINT32                SystemAffinityMask;
+  INT32                 LowBit;
 
+
   //
   // Enable the privilege so that RTC driver can successfully run SetTime()
   //
@@ -200,6 +204,20 @@
   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
   //  idle class. We need this to have good performance.
   //


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
edk2-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to