[Openmcl-cvs-notifications] r15131 - /trunk/source/lisp-kernel/thread_manager.c

gb at clozure.com gb at clozure.com
Sun Dec 11 21:52:51 CST 2011


Author: gb
Date: Sun Dec 11 21:52:51 2011
New Revision: 15131

Log:
get_tcr(): on Win32, check the linear field of the presumed TCR
address, don't just return a (possibly uninitialized) address in =

the TEB.

dequeue_tcr(): set tcr->linear to NULL on x8632, too.

Modified:
    trunk/source/lisp-kernel/thread_manager.c

Modified: trunk/source/lisp-kernel/thread_manager.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/thread_manager.c (original)
+++ trunk/source/lisp-kernel/thread_manager.c Sun Dec 11 21:52:51 2011
@@ -86,7 +86,7 @@
   }
   /* What if the suspend count is > 1 at this point ?  I don't think
      that that matters, but I'm not sure */
-  pcontext->ContextFlags =3D CONTEXT_ALL;
+  pcontext->ContextFlags =3D CONTEXT_FULL;
   rc =3D GetThreadContext(hthread, pcontext);
   if (rc =3D=3D 0) {
     return ESRCH;
@@ -787,7 +787,7 @@
   TCR_AUX(prev)->next =3D next;
   TCR_AUX(next)->prev =3D prev;
   TCR_AUX(tcr)->prev =3D TCR_AUX(tcr)->next =3D NULL;
-#ifdef X8664
+#ifdef X86
   tcr->linear =3D NULL;
 #endif
 }
@@ -1899,7 +1899,7 @@
 #ifdef HAVE_TLS
   TCR *current =3D current_tcr;
 #elif defined(WIN_32)
-  TCR *current =3D (TCR *)((char *)NtCurrentTeb() + TCR_BIAS);
+  TCR *current =3D ((TCR *)((char *)NtCurrentTeb() + TCR_BIAS))->linear;
 #else
   void *tsd =3D (void *)tsd_get(lisp_global(TCR_KEY));
   TCR *current =3D (tsd =3D=3D NULL) ? NULL : TCR_FROM_TSD(tsd);
@@ -2019,13 +2019,18 @@
       /* If the thread's simply dead, we should handle that here */
       return false;
     }
-    pcontext->ContextFlags =3D CONTEXT_ALL;
+    pcontext->ContextFlags =3D CONTEXT_FULL;
     rc =3D GetThreadContext(hthread, pcontext);
     if (rc =3D=3D 0) {
       return false;
     }
     where =3D (pc)(xpPC(pcontext));
 =

+    if ((where >=3D restore_windows_context_start) &&
+        (where < restore_windows_context_end) &&
+        (tcr->valence !=3D TCR_STATE_LISP)) {
+      Bug(NULL, "Forgot about this case ...");
+    }
     if (tcr->valence =3D=3D TCR_STATE_LISP) {
       if ((where >=3D restore_windows_context_start) &&
           (where < restore_windows_context_end)) {
@@ -2060,13 +2065,7 @@
           SET_TCR_FLAG(tcr,TCR_FLAG_BIT_PENDING_SUSPEND);
           ResumeThread(hthread);
           SEM_WAIT_FOREVER(TCR_AUX(tcr)->suspend);
-          SuspendThread(hthread);
-          /* The thread is either waiting for its resume semaphore to
-             be signaled or is about to wait.  Signal it now, while
-             the thread's suspended. */
-          SEM_RAISE(TCR_AUX(tcr)->resume);
-          pcontext->ContextFlags =3D CONTEXT_ALL;
-          GetThreadContext(hthread, pcontext);
+          pcontext =3D NULL;
         }
       }
 #if 0
@@ -2193,15 +2192,24 @@
     CONTEXT *context =3D TCR_AUX(tcr)->suspend_context;
     HANDLE hthread =3D (HANDLE)(TCR_AUX(tcr)->osid);
 =

+
+    TCR_AUX(tcr)->suspend_context =3D NULL;
     if (context) {
-      context->ContextFlags =3D CONTEXT_ALL;
-      TCR_AUX(tcr)->suspend_context =3D NULL;
-      SetThreadContext(hthread,context);
+      if (tcr->valence =3D=3D TCR_STATE_LISP) {
+        rc =3D SetThreadContext(hthread,context);
+        if (! rc) {
+          Bug(NULL,"SetThreadContext");
+          return false;
+        }
+      }
       rc =3D ResumeThread(hthread);
       if (rc =3D=3D -1) {
-        wperror("ResumeThread");
+        Bug(NULL,"ResumeThread");
         return false;
       }
+      return true;
+    } else {
+      SEM_RAISE(TCR_AUX(tcr)->resume);
       return true;
     }
   }



More information about the Openmcl-cvs-notifications mailing list